Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB4,VB5,VB6
Expertise: beginner
Apr 20, 1999

Hidden Variant variables

Variants are the default type of variables that are declared without an As clause, as in:


Dim name   ' this is a variant
or are not declared at all (which is only possible if the current module does not include any Option Explicit statement). If you are recycling programs written in Visual basic 1.0 or 2.0, or even QuickBasic, you might wish to include a DefSng A-Z at the very beginning of your modules, to make Single the default type as it was in those versions of the language. But the best approach is by far is using an explicit As clause for each declared variable.

A special case of this rule of thumb occurs when declaring more variables in the same line. Many developers, especially those that have programmed in C previously, are convinced that this line creates two Integer variables:


Dim x, y As Integer
while it actually makes x a variant variable. Since variant variables are generally much slower than Integer ones, you are going to have a performance hit if you do not pay enough attention to these details.
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date