DIM basically sets what your unsuffixed type is going to be.
Xpos& has a suffix. It's not affected by your DIM.
Dim Shared Xpos As XXX <--- here, you define your unsuffixed type to be an XXX-type
Dim Xpos as long <-- here, you try to define your unsuffixed type to be a LONG, but it tosses an error. You've already refined your unsuffixed type above.
If you like, think of them as:
x% -- integer
x& -- long
x! -- single
x# -- double
x$ -- string
x(nothing) -- Defaults to same as default variable type, unless you DIM it, then it's that type. Once DIMMED, you can't DIM it a different type.
Think of that x(nothing) as being an unique, one-define only shortcut type. Once you set it, you can't just unset it and retype it at the drop of a hat. %&!#$-types are all explicitly defined, and as such, they're not necessarily the same as your (nothing) type. (Though they can be...)
The above says that x(no sufffix) is going to be a shortcut for x&. That shortcut is now defined, and you can't define it again easily, without getting that DUPLICATE DEFINITION ERROR.
Xpos& has a suffix. It's not affected by your DIM.
Dim Shared Xpos As XXX <--- here, you define your unsuffixed type to be an XXX-type
Dim Xpos as long <-- here, you try to define your unsuffixed type to be a LONG, but it tosses an error. You've already refined your unsuffixed type above.
If you like, think of them as:
x% -- integer
x& -- long
x! -- single
x# -- double
x$ -- string
x(nothing) -- Defaults to same as default variable type, unless you DIM it, then it's that type. Once DIMMED, you can't DIM it a different type.
Think of that x(nothing) as being an unique, one-define only shortcut type. Once you set it, you can't just unset it and retype it at the drop of a hat. %&!#$-types are all explicitly defined, and as such, they're not necessarily the same as your (nothing) type. (Though they can be...)
Code: (Select All)
Dim x As Long 'this basically just creates a shortcut defining x as being the same as x&
x& = 123
Print x
The above says that x(no sufffix) is going to be a shortcut for x&. That shortcut is now defined, and you can't define it again easily, without getting that DUPLICATE DEFINITION ERROR.