Tutorial VB
Tutorial VB
When you want to group several controls together - name and address, for example - you
use a Frame. The frame backcolor can be the same as the form's and only the frame borders
will be obvious, or it can be a different color and stand out.
You create the frame before the controls. When you create controls in a frame, they are tied
to the frame and move with it. The frame caption is the text that appears at the top of the
frame - you use it to define the group.
These two controls are used when the user must choose from a list of options. The
difference between the two is that with Check boxes he can select several at one time but,
with Option buttons, he must select only one among several.
The example below illustrates the use of Check boxes and Option buttons. To capture the
information entered by means of these controls, you must test the property: Value. In a
Check box, Value = 1 if box is checked and = 0 if not. In an Option button,Value = True if
selected and = False if not.
The code, although somewhat long, is not very complicated. Most of the time, processing
consists of checking the content of .Value. It is fairly standard procedure, especially with
Option buttons, to ensure that at least one button has been selected and to display an error
message if it has not.
ListBox
With the ListBox control the user can select items from a list of choices. Although the list of
choices can be entered in the List property of the control, as in the example below, this is
not a very good habit to get into. It is essentially "hardcoding" data into the program and it
can cause maintenance headaches. The common technique for loading a ListBox is to do it
in code, with the Form_Load event. This way, if items have to be added it is a simple matter
to add a line of code.
In the above example the pictures were all added to the controls at design time.
You can also insert or remove a picture at run time. You use the LoadPicture function, as in:
pic_departmentlogo = LoadPicture("C:\Pictures\acctnglogo.bmp")
Removing the picture is done with the LoadPicture function without a file name:
pic_departmentlogo = LoadPicture ("" )