Sure.
Cs.c = 2
PRINT "Main Module: "; Cs.c
MySUB
PRINT "Main Module: "; Cs.c
PRINT "SUB TEST (): "; Cs.c
Cs.c = -1
PRINT "SUB TEST (): "; Cs.c
Now, I've fiddled a few other things because I'm strongly opinionated; others' tastes may be different:
- I renamed the User-Defined Type so it's different to the variable itself. I find it confusing when the same name is used in two different places.
- There is no "SHARED" line inside the sub, instead the Cs variable is DIM SHARED in the main program. I never use the SHARED-inside-a-sub technique because I get lost keeping track of everything.
- You can print multiple things by just separating them with ";", no need for another PRINT keyword :)
The main magic here is that you create a variable (Cs) with DIM SHARED, then that variable and all its fields can be used by all subs (and functions, of course).