|
-
Sep 5th, 2001, 12:42 AM
#1
Thread Starter
New Member
Help with module
Help getting rid of the module.
Can anyone offer some help? I'm a novice to VB and am trying to use a simplified code for minesweeper. I have got hold of a great code but it uses a Module and I would like to be able to put it all on to just the one form(there are reasons for this). I know nothing about "Types" I have tried to treat them as variables but
but that doesn't work. Any ideas ???
Module content
"Type square
mine As Boolean 'false = no mine, true = mine
stay As Double '0(not yet keyed), 1(keyed), 2(flagged)
near As Double 'mines near to squares
End Type"
-
Sep 5th, 2001, 12:59 AM
#2
PowerPoster
Hi
The Type ... end Type creates a definition of a user defined type which is essentially a 'complex' variable that can contain any other variables inside it. Once u declare the Type u then need to declare a variable of that type which u can then use as follows.
VB Code:
Private Type square 'Made private as is in one form
mine As Boolean 'false = no mine, true = mine
stay As Double '0(not yet keyed), 1(keyed), 2(flagged)
near As Double 'mines near to squares
End Type
Dim MySquare as square 'This creates ur variable
'You could also make an array eg Dim MySquare() as square
'When u refer to it in future, u refer to the variable and not the
'type, so (say, in a button click evnt)
With Mysquare
.mine = True
.stay = 2
.near = 2
End with
'Also, i am not sure why ur stay and near internal variables are
'doubles as surely bytes would do the job.
Regards
stuart
-
Sep 5th, 2001, 03:07 AM
#3
Thread Starter
New Member
Thanks beachbum
you got it in one and saved my day/week.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|