Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

what is up with the % sign?

Why do variables sometimes have a % sign with them?
For instance, someimes I see a loop like this:
For i = 0 to 7
...
Next i
and other times I see a loop like this
For i% = 0 to 7
--
Next %i
[242 byte] By [Athono] at [2007-11-11 7:37:11]
# 1 Re: what is up with the % sign?
The percent character following a variable indicates that the variable is an Integer. There's a list of VB's data types and their suffix characters here: http://www.geog.leeds.ac.uk/people/m.blake/magis/geog5080/lt2-1.htm . These days, it's generally preferred to use the "As <Type>" declaration syntax rather than to rely on data type suffix characters.
Phil Weber at 2007-11-11 17:26:39 >
# 2 Re: what is up with the % sign?
Yes... those symbols are type-declaration suffixes. You might see them used because some coders believe that it increases performance. It does marginally, but only in the IDE. Once compiled, there is no difference between "Dim i%" and "Dim i As Integer".
However, these symbols can still be useful when it comes to literals. To test this, you can recreate this in your immediate pane...
?&hffffff ' type Integer(%) assumed
-1
?&hffffff& ' type Long(&) specified
65536
FauxQuixote at 2007-11-11 17:27:42 >