Table of Contents
Formatting and Arrays
The Format$ function converts values into strings according to certain fixed patterns or according to patterns you provide. The syntax is:
Visual Basic shares code through
To use a custom control, you must place the control's VBX file in the System folder of Windows. Visual Basic will add the filename to the project file list that is displayed in the Project Window. You can place procedures you want available to more than one form in a code module.
The scope of a variable is determined by its visibility and lifetime. Visibility is a question of what procedures can use (or "see") a variable. The lifetime of a variable depends on whether the value of the variable is available apart from the limited lifetime of an event procedure. A variable declared and used in one event procedure is not available in another. Variables declared in the form module are available to all event procedures within the form. Variables declared with the Global statement in a code module are available to any form in the project and its event procedures.
A static variable, declared within van event procedure, isn't available to other procedures, but its value does persist beyond the end of the procedure in which it is declared. When the procedure is reentered, the static variable is there, with its old value, available for use.
The Option Explicit statement is entered in the general declarations section of either a form module or a code module. By using this statement, you require that each variable be declared before use.
You use arrays so that you can save a list of values. The list has a single name. Each element of the list has a unique whole number subscript. For instance, an array of names can be declared as follows:
Another way to declare the same array:
The first characters of the name, gstr, shows the data type of the variable. The prefix g indicates the variable is global; the str shows that the variable contains strings.
The blackslash (\) operator divides two numbers and gives the whole number result.
Prompt is a string containing the instruction to the user. Caption is the caption of the window. Default Value is a string representing a default value for the variable. If a user presses Enter without changing the default value, this value is assigned to the variable.