|
|
Visual Basic
Introductory Activity
Follow the instructions below. The items in
italics should be typed into the appropriate portion of the
program exactly as specified.
- Open a new Visual Basic Project.
- Save the project in your folder using
???intro as the name where ??? is your initials. When you
initially save the project, make sure you open up your folder in
the menu before saving.
- Make the caption of the form be Your Name -
Introductory Activity.
- Use the label tool to create a label on the
form. Make the name be lblNum1. The caption should be
Enter a number in each text box. Move all labels and text
boxes to the right side of the form as the left side will be used
by the output from the program.
- Use the text box tool to draw two text boxes
on the form naming them txtNum1 and txtNum2. Using
the text property, delete the text in the text box.
- Use the command button tool to draw a command
button on the form. Make the name be cmdSum and the
command button caption be Print the Sum.
- Double Click on the cmdSum command button to
open the code window. In the private sub cmdSum subroutine, enter
the following code: Form1.Print "The sum of ";txtNum1; " and ";
txtNum2; " is "; val(txtNum1)+val(txtNum2) . Note that val()
is a new function. It converts numbers in a text box to numeric
format so that they can be used in mathematical equations. Good
output always repeats the input. Hence the statement above will
appear as "The sum of 2 and 3 is 5".
- Add command buttons for subtracting,
multiplying and dividing the two numbers. Appropriately name and
caption the command buttons. Add a print line similar to the one
above which will print the difference, product, and quotient of
the two numbers in the text boxes.
- Save the program.
Visual Basic Assignment
Page
|
|