VBA Primer - Part 2
When you insert the form you might have noticed that another dialogue popped up. This is the Control Dialogue Toolbox. It look's like this :
To add a control to your form, select the desired control and click on the form in the position that you would like the control to be. Select the CommandButton control and place it on your form. Your form should now look like this :
Now, using the properties panel, change the properties of the command button to the following :
(Name) CommandButton1 Caption OK Default True Font Arial - Bold - Size 8 Accelerator O
Your button should now look like this :
The Caption property is, of course, the text that appears within the button. The Default property means that if Enter is selected the event procedure asSigned to this control is triggered. The Accelerator property is the letter of the caption that needs to be selected, along with the Ctrl key, to select this control.
Now add the following controls to your form and change the properties to the values listed below :
Command Button
(Name) CommandButton2 Cancel True Caption Cancel Accelerator C Font Arial - Bold - Size 8
The Cancel property means that if Esc is selected the event procedure assigned to this control is triggered.
Label
(Name) Label1 Caption Choose Layer: Font Arial - Bold - Size 8
List Box
(Name) Listbox1 Font Arial - Bold - Size 8
You can move a control by simply dragging and dropping it. To re-size it, just grip the re-size boxes at the edges and corners of the control. Now move and re-size your controls and the form until the dialogue box looks similar to this :
Note: Do you see how easy it is to create dialogue boxes in VBA compared to DCL. "What a pleasure!"
Now that we have got our basic dialogue box we need to make it do something. Part 3, look out, here we come…