Tip Bank

DevX

Enhanced For-Next loops

At times you may need to execute the same block of statements for different values of a variable, but you can’t use a straight For Next loop because the sequence

DevX

Short-circuit evaluation with Select Case

Short-circuit evaluation is an optimization technique automatically adopted by most modern compilers, including all flavors of C++, Borland Delphi and many others. Unfortunately, the Visual Basic compiler is not in

DevX

Create stand-alone type libraries

Many VB programmers assume that Visual Basic 5.0 is not capable of creating stand-alone Type Libraries, because the documentation states that when an ActiveX component or control is created, the

DevX

Fixed-length strings allocate and deallocate faster

Fixed-length strings are generally slower than conventional strings, because all VB string functions and operators only recognize conventional strings, thus all fixed-length strings must be transparently converted to and from

DevX

UserName – The name of the interactive user

Private Declare Function GetUserName Lib “advapi32.dll” Alias “GetUserNameA” _ (ByVal lpBuffer As String, nSize As Long) As Long’ The name of the interactive userFunction UserName() As String Dim buffer As

DevX

ByVal with object references

When you write a procedure and you want to be sure that the procedure does not affect the value of any variable passed to it as an argument in the

DevX

The number of dimensions of an array

Using “pure” VB, the only way to build a generic routine that returns the number of dimensions of an array passed as an argument is using a loop that repeatedly

DevX

Passing Public class variables by reference

Under VB4 Public variables in form and class modules were implemented in the same manner as variables in BAS modules, that is, as direct references to memory locations. This allowed