In VB6, certain suffixes can be added to specify a variable type. For instance:
Dim x%
Is the same as:
Dim x As Integer
The suffixes are still supported in VB.NET, but they are widely discouraged. Here is the list of possible suffixes:
$
is the suffix for String
%
is the suffix for Integer
&
is the suffix for Long
!
is the suffix for Single
#
is the suffix for Double
@
is the suffix for Currency
(now Decimal
in .NET)
VB6 did not provide suffix characters for all of the core data types. For instance, there is no valid suffix character for Boolean
, Date
, or Short
. Even in VB6, many people recommended always using As
in all variable declarations, but there were still many people who recommended using the suffixes, where available, because they provided some additional pre-compile type-checking which was often beneficial.
So, to convert that code to .NET, you'd want to replace the suffix symbols in any variable declaration lines with an As ...
clause, specifying the equivalent type, for istance, instead of this:
Dim Er!, Derivative!, Proportional!
Static Olderror!, Cont!, Integral!
Static Limiter_Switch%
You'd convert it to this:
Dim Er, Derivative, Proportional As Single
Static OldError, Cont, Integral As Single
Static Limiter_Switch As Integer
And then, where ever a suffix symbol appears when a variable is being used, outside of a declaration line, you can just remove the symbol. For instance, instead of this:
Limiter_Switch% = 1
You'd convert it to this:
Limiter_Switch = 1
Bear in mind, when converting types from VB6 to VB.NET, that the numeric types in VB.NET are larger. So for instance, Integer
in VB6 is 16-bit, but in VB.NET, Integer
is 32-bit. So, technically, the equivalent in VB.NET, for a VB6 Integer
is Short
. Typically, it doesn't matter, and you just want to use Integer
for Integer
, but if the number of bits matters, you need to be careful.