Option Private Module Statement

Restricts the scope and visibility of the contents of a module i.e., its variables, classes, functions, and procedures in VBA-enabled applications that allow references across multiple projects e.g., Microsoft Office applications to the module's project. Option Private Module has no effect in the standalone version of Visual Basic. The Option Private Module statement must appear in the declarations section of a module before any procedures. 446 Chapter 7- The Language Reference Publicly...

Chr Chr ChrB ChrB ChrW Functions

Chr charactercode Chr charactercode ChrB charactercode ChrB charactercode ChrW charactercode charactercode An expression that evaluates to either an ASCII or DBCS character code. Chr, ChrB, and ChrW return a variant of the string subtype that contains the character represented by charactercode. Chr and ChrB return a string containing the character represented by char- Returns the character represented by charactercode. Chr and Chr return the character associated with an ASCII or ANSI character...

Creating a Dynamic Control Array

To create a dynamic control array that is, an array of controls you can add to at runtime you must first place a control of the required type on the form and set its index property to 0. You can then use the Load statement to create new controls based on the control whose Index is 0. The new controls inherit all the properties of the original control, including its size and position. This means you must set the Left and Top properties for the new controls otherwise, all your controls will sit...

Printer Object and Printers Collection

Since it's part of the VB library, the Printer object isn't available to VBA applications. When you write a VBA as opposed to VB program, you simply make use of the host application's own built-in printing functionality. For example Set oWordActiveDoc oWord.Documents.Add Set oWordSel oWord.Selection oWordSel.TypeText This is text coming in from the VB app. oWordSel.Font.Name Arial Visual Basic contains a global printer object, which refers to the default printer for the current system. Because...

Class Module Properties

Depending on the type of project in which the class module .cls file is included, class modules support the following properties that control their precise behavior Only available when a class is part of an ActiveX project, the instancing property defines how instances of the class are created. Its values are The class becomes global to the project in which it's defined references are not necessary. For example, most VB language objects are global as soon as you load the environment, they are...

Asc AscB AscW Functions

Asc string AscB string AscW string string Any expression that evaluates to a string. Return Value An integer that represents the character code of the first character of the string. The range for the returned value is 0-255 on non-DBCS systems, but -32768-32767 on DBCS systems. Returns the ANSI or Unicode character code that represents the first character of the string passed to it. All other characters in the string are ignored. Use AscB with Byte data and AscW on Unicode DBCS systems. The...

Delete Setting Statement Named Arguments

DeleteSetting appname , section , key appname The name of the application. This must be a subkey of the HKEY_ CURRENT_USER Software VB and VBA Program Settings registry key. The name of the application key's subkey that is to be deleted. section can be a single key or a registry path separated with backslashes. The name of the value entry to delete. Description Deletes a complete application key, one of its subkeys, or a single value entry from the Windows registry. section can contain a...