Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

410 Part III Designing the User Interface



  1. Modify the Button1_Click event procedure as follows. (The shaded lines are the ones
    that you need to change .)


Dim Employee As New Teacher
Dim DOB As Date

Employee.FirstName = TextBox1.Text
Employee.LastName = TextBox2.Text
DOB = DateTimePicker1.Value.Date
Employee.Grade = InputBox("What grade do you teach?")

MsgBox(Employee.FirstName & " " & Employee.LastName _
& " teaches grade " & Employee.Grade)
In this example, I’ve removed the current age calculation—the Age method isn’t
used—but I did this only to keep information to a minimum in the message box.
When you define properties and methods in a class, you aren’t required to use them
in the program code.
Now you’ll run the program.

Tip The revised Person Class program is located in the C:\Vb10sbs\Chap16\Person Class
folder.


  1. Click the Start Debugging button to run the program.


The new employee form opens on the screen:


  1. Type your first name in the First Name text box and your last name in the Last Name
    text box.

  2. Click the date/time picker object, and then scroll to your birth date.

Free download pdf