709-218-7927 The Landfall Garden House 60 Canon Bayley Road Bonavista, Newfoundland CANADA A0C 1B0 |
---|
Creating a GUI Form.
We now set off on the second segment of the course – GUI forms. By the end of the course you will have developed a GUI form. This GUI form, developed completely within Excel, can be exported, then imported for immediate use in Word VBA – a powerful example of the mobility of your new skills.
Creating a GUI form is easy. Switch into the VBE and choose Insert, UserForm.
An embryonic user form will appear before you. Tap the F5 function key to execute the form, and your naked form will appear before you over your Excel worksheet. Click the “x” in the top right hand corner of the form to shut down the form; later we will build a Cancel button to close the form.
Save your work frequently.
In VBE choose View, Properties and change the name of the form to be “frmMyUser”; change the caption to be “My User Form”.
The Toolbox should be visible; if it is not, in VBE ensure that the Toolbox is set (View, Toolbox) and click once on the user form.
Hover your mouse over each icon in the ToolBox to inspect the name.
Drag a TextBox, a ListBox and two Command Buttons onto the form.
Click on the text box to select it and (Properties) change its name to “tbInput”; the prefix “tb” reminds us that it is a “t”ext "b"ox.
Click on the list box to select it and (Properties) change its name to “lbProvinces”; the prefix “lb” reminds us that it is a “l”ist "b"ox.
Click on the first command button, change its name to “cmdCancel”, change the caption to be “CANCEL” and set the Cancel property to be True.
Click on the second command button, change its name to “cmdOK”, change the caption to be “OK”.
Run the GUI form by tapping the F5 function key. The form appears, but clicking the command buttons or tapping the Escape key has little effect yet. Close the form by clicking the “x” in the top right-hand corner.
In the next lesson we will assign program codes (instructions) to the command buttons.
709-218-7927 CPRGreaves@gmail.com Bonavista, Sunday, December 08, 2024 9:31 AM Copyright © 1990-2024 Chris Greaves. All Rights Reserved. |
---|