Visual Basic - Be On The Lookout For Those Sneaky Variant Variable (VB 6)


As developers we use so many different languages these days, it's sometimes hard to see our programming mistakes. This is especially true when the job requires us to move between a non-compiled language like VBScript and Visual Basic 6. One of the most common mistakes that could wreak havoc on an application's performance is in the area of variable declarations. Too many variant variables can and will weigh down an executable. Following are two of the more common culprits that can cause unwanted variants to sneak into your application:


  • Dim x, y as integer
  • Dim z

In the first statement, x will be typed as an Integer but, y will be a variant. Likewise, z will be a variant because the Data Type information is absent.

Go back