1. Home
  2. Computing & Technology
  3. Visual Basic

Chapter 4 - Working With Menus and Dialog Boxes - Part 3

By , About.com Guide

10 of 10

Notes about the Solution Code - Page 5

Again, this isn't required to make a working program. You could just have them in different places on the form. (But if you did that, it would be a good idea to also change the Enabled properties so the user couldn't click the wrong button.) This is just a design technique that I thought you might like to see.

Finally, notice that the declaration of one variable is hanging out there by itself at the very top of the program:

~~~~~~~~~~~~~~~~~~~~~~~~~
Dim IndexValue As Integer
~~~~~~~~~~~~~~~~~~~~~~~~~

This is something that you really haven't seen before in this course. But again, you could get the same result with code that isn't quite as interesting.

The reason IndexValue is declared before any procedures is to make it global to all of them. That is, any procedure will have access to this variable when it's declared this way. Since I use this variable in both the Button1_Click subroutine and the Button3_Click subroutine, this is one way to allow both to access it. This is part of a larger topic called "scope of variables" that we'll see again.

This brings us to the end of Part I of our text and Part I of our lessons, too! Happy coding!

Explore Visual Basic
By Category
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB.NET
  5. Working With Menus and Dialog Boxes - Part 3

©2009 About.com, a part of The New York Times Company.

All rights reserved.