Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

Chapter 10 Creating Modules and Procedures 267



  1. In the Code Editor, just below the Form1 .vb tab name, click the Class Name arrow,
    and then click the btnMkt object in the list. Then click the Method Name arrow,
    and click the Click event.
    The btnMkt_Click event procedure appears in the Code Editor. Using the Class Name
    and Method Name list boxes is another way to practice adding event procedures.

  2. Type the following statements in the event procedure:


Dim MktPosition As String = ""
AddName("Marketing", MktPosition)
txtMkt.Text = txtMkt.Text & MktPosition
This event procedure is identical to btnSales_Click, except that it sends “Marketing”
to the AddName procedure and updates the txtMkt text box. (The name of the local
return variable MktPosition was renamed to make it more intuitive .)


  1. Click the Class Name arrow, and then click the btnQuit object in the list. Then click the
    Method Name arrow, and click the Click event.
    The btnQuit_Click event procedure appears in the Code Editor.

  2. Type End in the btnQuit_Click event procedure.

  3. Click the Save All button on the Standard toolbar, and then specify the
    C:\Vb10sbs\Chap10 folder as the location.
    That’s it! Now you’ll run the Text Box Sub program.


Run the Text Box Sub program

Tip The complete Text Box Sub program is located in the C:\Vb10sbs\Chap10\Text Box
Sub folder.


  1. Click the Start Debugging button on the Standard toolbar to run the program.

  2. Click the Add Name button under the Sales text box, and then type Manuel Oliveira
    in the input box. (Feel free to type a different name .)
    Your input box looks like this:

Free download pdf