Hungarian variable names

Tags
Summary

"Sales tax rate" is sSalesTaxRate. Price is just sPrice.

Situation

You need to name some variable names.

Action

The first character or two tell you the data type of the variable.

Type Start with Example Notes
Single s Dim sGoatWeight As Single
String t Dim tGoatName As String t stands for "text." s is already being used for Single.
Boolean b Dim bIsGoatCool As Boolean Booleans often start with bIs or bCan.
Range r Dim rGoatData As Range
Array of Singles as Dim asPrices(1000) As Single
Array of Strings at Dim atAddresses As String

After the data type letters, use one or more words. The first character of each word is uppercase, like tGoatEyeColor.

Use names that explain what the variable is. Long names are OK. For example, instead of tGtLn, use tGoatLastName.

Don't forget Ctrl+Space when you're writing code. Type the first few characters of a variable's name, then hit Ctrl+Space. VBE will show you the symbols that start with those characters. Faster, and fewer spelling errors.

Where referenced