Ie 212 homework - string manipulation input boxes and


Homework - String Manipulation, Input Boxes and Message Boxes

PROBLEMS -

Open a blank Excel workbook and save it as a MACRO-ENABLED file. Your workbook must contain only two worksheets named "Prob1" and "Prob2", respectively. Open the Visual Basic Editor (VBE) and insert a new module into the Project Explorer. You must write (NOT record) all your sub procedures inside this module.

1. Problem 1 (see Figure 1).

An Internet Protocol (IP) address is a numerical label assigned to each device in a computer network (e.g., computer, printer, etc.) To simplify their interpretation, IP addresses are represented as four decimal numbers separated by periods (e.g., 131.65.10.18). This representation is known as dotted decimal notation. The number of decimal numbers of an IP address that are used for the network identification (ID) number and the host ID number depend on which class it belongs to. For example, Class B IP addresses use the first two decimal numbers for the network ID and the remaining two decimal numbers for the host ID. Thus, in the Class B IP address 168.212.226.204, "168.212" identifies the network ID and "226.204" identifies the host ID.

a) Add a module (i.e., Module1) in the Project Explorer and write (do NOT record) all the code for this problem inside this module. Show your results in the worksheet labeled "Prob1."

b) Write a sub procedure named ipAddress that takes a user-provided Class B IP address in dotted decimal notation from cell C6 and does the following:

Displays the network ID portion of the IP address in cell C8. For this problem, assume that the first decimal number of the IP address is restricted to values from 128 to 191 and that the second decimal number can assume any value between 1 and 255.

Display the host ID portion of the IP address in cell C9. For this problem, assume that the third decimal number of the IP address can assume any value between 0 and 255 and the fourth decimal number is restricted to values from 1 to 255.

Display the individual decimal numbers of the IP address as follows:

  • First decimal number → Cell C10
  • Second decimal number → Cell C11
  • Third decimal number → Cell C12
  • Fourth decimal number → Cell C13

Cells B8, B9, B10, B11, B12 and B13 should display the labels "Network ID:", "Host ID:", "1st decimal:", "2nd decimal:", "3rd decimal:" and "4th decimal:", respectively.

Select cell A1 once sub procedure terminates execution.

Assign the sub procedure to a shape button labeled "IP Address Information".

c) Write a sub procedure named clearIPData to clear the contents of range C8:C13. Assign the sub procedure to a shape button labeled "Clear IP Address Data".

1073_figure.png

2. Problem 2 (see Figure 2).

A simple pendulum consists of a weight suspended on a string or wire. If the pendulum weight is pulled to a relatively small angle from the vertical and let go, it will swing back and forth at a regular period (T) and frequency (f). The period of the motion of a pendulum (i.e., how long it takes the pendulum to swing back-and-forth) is measured in seconds. The frequency of a pendulum (i.e., how many back-and-forth swings there are in a second) is measured in hertz. The period T is the reciprocal of the frequency and vice versa (i.e., T = 1/f and f = 1/T). The formula to calculate the period of a pendulum as a function of the length of the wire and the acceleration due to gravity is:

T = 2 * π * √(L/g)

Where:

L = Length of the wire (in meters).

g = Acceleration due to gravity (∼9.8 m/s2)

a) Add a module (i.e., Module2) in the Project Explorer and write (do NOT record) all the code for this problem inside this module. Show your results in a worksheet labeled "Prob2."

b) Write a sub procedure named periodPendulum that does the following:

Prompts the user for the length of the wire (L) in meters via an input box. Assume that the user always enters a valid value for L. Therefore, you do NOT need to implement any validation procedure for the input in this problem.

Calculates the period with equation (1) shown above.

Displays the period (T) and frequency (f) in separate lines within a message box.

Displays the values of L, T, and f in the spreadsheet. You are at liberty to decide where to display and how to format the results. Minimal work will get minimal grading.

Clears the values of L, T, and f from the spreadsheet every time the sub procedure is executed at the beginning of the sub procudure.

Selects cell A1 once the sub procedure terminates execution.

c) Assign the sub procedure to a shape button labeled "START".

2185_figure1.png

Requirements for BOTH problems:

Assign the input values entered by the user (either via an Input Box or entered into the spreadsheet) to variables of the appropriate type.

Make sure your program does not experience any flickering when processing the input data or producing results.

Make sure to follow good programming practices. In particular, pay close attention to the following:

  • Explicitly declaring all variables;
  • Properly indenting code so that it is more readable; and
  • Adding comments to your code.

Request for Solution File

Ask an Expert for Answer!!
Dissertation: Ie 212 homework - string manipulation input boxes and
Reference No:- TGS02679585

Expected delivery within 24 Hours