The top right combo box in the code window will display all relevant events for the current control object.VBA Excel is Microsoft's internal coding language for Excel and other Office systems. It should be noted than each control only uses a subset of events. The top one is ∜ancelEntry_Click and the bottom is ∝ecimal_Click.īelow is a list of all Visual Basic events. The horizontal line drawn half way down the window signifies a division between two different subroutines. Note: Since version 4 of VB the code window can display multiple procedures. In the example below the window is currently showing code associated with the Click event of the CancelEntry_Click control object. Any event for the current control can be selected by using the right hand drop-down menu. Once the correct control object has been selected the next step is to choose which event the control is going to respond to. The screen shot below shows a window displaying code for the ∜E command button (CancelEntry). The final step is writing the code that activates the application, or makes it run. Selecting the property BackColor, dropping down the colour palette and selecting the required colour cell. This was achieved by selecting the label object. In the VB sample application, the calculator readout background colour is yellow. This done by typing, or by selecting from a pre-defined list of possible values (obtained by clicking on the down arrow to the right of the settings list - if this is activated). When the property value you want appears in the settings box it can be edited. This displays the current value of the property selected from the properties list underneath it. Just below the object box is the settings box. This is a list box that can be used to select any of the objects on the current form. The object box (under the properties title bar) then displays the name of the object. To set the properties of a screen object. In the calculator example above, the command buttons have been given captions corresponding to symbols such as ∑, −, %, =.
If this is not visible use the Windows menu to invoke it. Properties are set using the properties window. The familiar buttons are created using command buttons and the readout appears in a label. Here is the interface for the calculator that is supplied as a sample application in. Clicking and dragging on sizing handles allows the object to be sized horizontally and/or vertically. Moving the mouse over a sizing handle changes the cursor to a double headed arrow. Clicking on the object reveals sizing handles as shown around the horizontal scroll bar below: From here the object may be dragged into place using the mouse. That object appears in the centre of the form. To place a control on Form1, double click on a toolbox icon.
This is where the interface (or the first screen of the interface) is constructed. In design mode VB presents a blank form, labelled Form1. You may also load an application that has been previously saved, run it, or continue to work on it. This means that the system is ready for you to start to build an application. When you launch VB the environment is in design mode (see title bar). VB Help gives a brief description of each toolbox icon (click on the search button then enter tool, double click on toolbox in the lower window), refer to this if unsure about which item to choose. One must also understand the characteristics of the various screen objects in order to make good choices for the interface. This step is often described as providing the functionality.īefore setting out to write a program, one must have a task in mind. Writing program code to specify what will happen as users interact with the screen objects. Setting the properties of the screen objects to change such things as colours and labels. Screen objects (or controls) are selected from the toolbox, placed and sized using the mouse. This is done interactively without the need to program.
The professional option contains a wider variety of controls in the toolbox.Ĭreating a program is as simple as 1, 2, 3:ĭesigning the interface. At this point select either Standard EXE or VB Professional Edition Controls. If VB has been sucessfully started a dialog box like the one below should be seen. There are two ways to do this:Ĭhange directory to N:\Msoft\DevStudio\VB5 Before any programming can begin Visual Basic itself must be located and run.