Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
DECLARE Statement (Basic Procedures) Details
◄Summary► ◄Details► ◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
DECLARE {FUNCTION | SUB} name [([parameterlist])]
Usage Notes
■ If the variable defined in the parameterlist is an array, it can be
followed by the number of dimensions in parentheses. For example:
DECLARE SUB DisplayText (A(2) AS STRING)
DIM Text$(100,5)
.
.
.
CALL DisplayText(Text$( ))
■ The number of dimensions is optional; however, the empty parentheses
should be included.
■ If a parameter is passed by reference, any change to the parameter
value inside the procedure changes its value in the calling program.
■ If a parameter is passed by value, any changes to the parameter value
inside the procedure is local to that procedure and does not affect its
value in the calling program.
■ For calls within Visual Basic, the DECLARE statement is required only if
you call SUB procedures without the CALL keyword, or if you invoke a
FUNCTION procedure defined in another module.
■ A DECLARE statement also causes the compiler to check the number and
type of arguments used to invoke the procedure. Visual Basic
automatically generates DECLARE statements when you save your program
in the programming environment (VBDOS).
■ The DECLARE statement can appear only in module-level code (not in a
SUB or FUNCTION procedure) and affects the entire module.
■ The form of parameterlist determines whether or not argument checking
is done. For example:
Example Description
═════════════════════════════ ════════════════════════════════════
DECLARE SUB First You can omit the parentheses only if
the SUB or FUNCTION procedure is
separately compiled. No argument
checking is done.
DECLARE SUB First () First has no parameters. Arguments
in a call to First generate an error.
An empty argument list indicates
that the SUB or FUNCTION procedure
has no parameters and that argument
checking should be done.
DECLARE SUB First (X AS LONG) First has one long-integer parameter.
The number and type of the arguments
in each call or invocation are
checked when the argument list
appears in the DECLARE statement.
■ You cannot have fixed-length strings in DECLARE statements. Only
variable-length strings can be passed to SUB and FUNCTION procedures.
Fixed-length strings can appear in an argument list but are converted
to variable-length strings before being passed.
■ You can have arrays containing fixed-length strings in DECLARE
statements. The lengths of the array in the CALL statement and the
declaration must match.