Name of variables: an issue
#4
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...)

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.
Reply


Messages In This Thread
Name of variables: an issue - by TempodiBasic - 08-30-2022, 06:12 AM
RE: Name of variables: an issue - by SMcNeill - 08-30-2022, 06:18 AM
RE: Name of variables: an issue - by TempodiBasic - 08-30-2022, 03:01 PM
RE: Name of variables: an issue - by SMcNeill - 08-30-2022, 03:32 PM
RE: Name of variables: an issue - by TempodiBasic - 08-31-2022, 11:47 PM
RE: Name of variables: an issue - by TDarcos - 09-09-2022, 01:25 PM
RE: Name of variables: an issue - by mnrvovrfc - 09-09-2022, 04:19 PM
RE: Name of variables: an issue - by mnrvovrfc - 09-09-2022, 04:33 PM
RE: Name of variables: an issue - by TDarcos - 09-26-2022, 12:52 AM
RE: Name of variables: an issue - by mnrvovrfc - 09-26-2022, 05:13 AM
RE: Name of variables: an issue - by Pete - 09-26-2022, 08:18 PM
RE: Name of variables: an issue - by Petr - 10-01-2022, 07:21 PM



Users browsing this thread: 15 Guest(s)