Variable Builder
Declares variables without moving from the current position. The variable is
added at the top of the procedure, in the procedure's interface or in a selected
module. A copy can be pasted at the current position using ctrl-v, the place
where you actually use it. The builder saves time by:
- not having to move to the declaration section and back
- copying the variable so it is available thru clipboard (ctrl-v)
- automatically selecting type based on used prefix in name.
- pick up name from selected text
- inserts standard statements for object variables.
Start this dialog from Toolbar
or using
Alt-CVA (Code-vb - Variable - Add)
The name is kept on the clipboard and can be inserted directly at the
position you are working using Ctrl-V.
Alternative: use fast declaration if you only need simple procedure
level variables thru menu: Variable > {variable type}
Controls:
Accessibility
Select if a variable is to be Public or Private or procedure or module level
or part of the interface.
Name
If you use prefix (lowercase) the builder will automatically try to
interpret type, level and, if it is in the interface, ByRef/ByVal. Prefixing
behavior can be changed in the
Settings dialog.
Type
Select the type of the variable. While entering characters the type gets
selected incrementally. Selecting type may change prefix. Prefixing behavior
is defined in the
Settings dialog.
Length
Only in case of strings, let's you specify the length of the string
Is Array
and Array Dimensions
Enter array dimensions the normal way, e.g.
- 1 To 3, 1 To MAXCOLS
Description
For those professional developers who take documenting code seriously :).
The description is added after the declaration, e.g.
- Dim sFile as String ' File to be processed
or below the procedure interface
if it is part of that, e.g.
- Sub ProcessFile(sFile as String)
- ' File to be processed
Interface
Set these to define how and where a variable is to be defined as a
procedures argument. To indicate it is to be a procedures argument you have
to set
Accessibility to 'Interface'
ByVal
ByVal allows the procedure to access a copy of the variable. As a result,
the variable's actual value can't be changed by the procedure to which it is
passed. As opposed to ByRef in which the variable is shared between the
calling and called procedures.
ParamArray
Used only as the last argument in arglist to indicate that the final
argument is an Optional array of Variant elements. The ParamArray keyword
allows you to provide an arbitrary number of arguments. ParamArray can't be
used with
ByVal, ByRef, or
Optional.
Optional
Optional indicates that an argument is not required when calling the
procedure.
Default
Any constant or constant expression to be used when the procedure is called
without specifying the Optional argument. If the type is an Object, an
explicit default value can only be Nothing.
Before Argument
By selecting one of the existing arguments you can explicitly set where the
variable is to be added in the procedure's interface. If nothing is selected
it is put as last.
Object
By checking all options you can have all these statements inserted in one go
(example inserting rng as Range variable):
- Dim rng As Range
Set rng = New Range
With rng
End With
Set rng = Nothing
Set = New
Create an instance of the object.
With ...
Efficient way to call a series of properties and methods, e.g.
-
With rng
.Font.Bold = True
.Select
End With
Set = Nothing
Explicitly free memory and system resources used by objects.
Module
If you use global variables (accessibility)
and keep them in an other then the current module. You can select this module
here, which saves you a trip to the other module and back.
OK
Creates the variable in the declaration section.
OK & Paste
Creates the constant in the
declaration section and pastes it at the cursor position.
Cancel
Closes the builder without creating the variable
Help
Starts this Help topic