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.

  1. Open a new Visual Basic Project.
  2. Save the project and file in your ulocker folder using 00???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.
  3. Make the caption of the form be Your Name - Introductory Activity.
  4. 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.
  5. 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.
  6. 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.
  7. 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".
  8. 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.
  9. Save the program.

 

Visual Basic Assignment Page

 
51731

 

 
© 2004-2008, Jerel L. Welker
Page Updated: January 15, 2009