Use integer division operator
Use “” instead of “/” when performing divisions between Integers. The “/” operator returns a Single value, therefore the seemingly efficient line C% = A% / B% actually requires three
Use “” instead of “/” when performing divisions between Integers. The “/” operator returns a Single value, therefore the seemingly efficient line C% = A% / B% actually requires three
VB stores symbolic and literal constants internally using the simplest data type possible; this means that most common numeric constants-such as zero or one-are stored as Integers. If you use
Private Declare Function GetShortPathName Lib “kernel32” Alias _ “GetShortPathNameA” (ByVal lpszLongPath As String, _ ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long’ Convert a long filename into the
You can’t reliably test an auto-instancing object variable using the Is Nothing test, because as soon as you reference the variable Visual Basic silently creates an object of the given
The StartLogging and LogEvent methods of the App object only work in compiled applications. This behavior is by design and shouldn’t be considered a bug, even though it isn’t documented
If your application uses objects from external components, either third-party or your own libraries, a good rule of thumb is to include the complete servername.classname string in the Dim statement,
‘ Return the string of code the is selected in the code window’ that is currently active. ‘ This function can only be used inside an add-in.Function GetSelectedText(VBInstance As VBIDE.VBE)
‘ Returns the name of the current project’ The first time it’s called it clears the error code’Function ProjectName() As String Static result As String If Len(result) = 0 Then
‘ ShellSort an array of any type” ShellSort behaves pretty well with arrays of any size, even’ if the array is already “nearly-sorted”, even though in’ particular cases BubbleSort or