Variables

A variable is just a named storage location in memory. At the top of all your modules you should have "Option Explicit" to force explicit declaration.
Variables are case sensitive in C#.
Variables that are not defined explicitly have the "Variant" datatype assigned to them by default.
Variables can accommodate a wide variety of datatypes from simple boolean values to extremely large 20 digit numbers.


In C# assigning values to variables and comparing values are treated as two very different operations.
Because of this they have different symbols
= - for assignment
== - for comparison
In VB this is the same symbol (=).


Prefix private variables with an underscore "_"
Use Pascal casing for public variables
Use Hungarian notation for private or local variables
Always try and declare your local variables at the very top of the method and not amongst lines of code
Do not use language specific type names. For example use Int16 instead of Short


Hungarian Notation

This is defined as a set of characters that are added to the start of variable names to indicate their datatype
sFirstName, iYears, objRecordSet

Dim sMyString As String 


Camal Notation

Initial lowercase for variable names
This is when the first character of each word is a capital, except the first word
myCounter, numberOfDays, foreColor

Dim variableName As Object 



Pascal Notation

Initial uppercase for variable names
This is when the first character of each word is a capital
MyCounter, NumberOfDays, ForeColor

Dim VariableName As Object 




© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

Top

PrevNext