Should they be declared at the very top or inline ??

Variable Names

The first character must always be alphabetic.
You cannot use spaces or periods.
Variable names can use alphabetical characters, number and some punctuation characters but not ( * . , # $ % & !).
The use of the underscore character is also encouraged.
The name must start with a letter and can have a maximum of 254 characters.
A variable must begin with a letter or an underscore
Variable names can be constructed from letters and numbers and the underscore character.
Variable names cannot be the same as C# keywords.

Case Sensitive

Multiple Variables

string firstName, lastName; 

This statement is valid although the variable sFirstName is defined as a Variant variable and not as a string variable.

Dim sFirstName, sLastName As String 

VBA does not let you declare a group of variables to all be of the same data type.
You must specify the type of each variable explicitly.
You should always try and declare each variable on a separate line

Dim sFirstName As String 
Dim sLastName As String

You could put this on one line

Dim sFirstName As String, sLastName As String 

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext