Results 1 to 3 of 3

Thread: Help with module

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2001
    Location
    Australia
    Posts
    14

    Question 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"

  2. #2
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    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:
    1. Private Type square  'Made private as is in one form
    2.      mine As Boolean 'false = no mine, true = mine
    3.      stay As Double '0(not yet keyed), 1(keyed), 2(flagged)
    4.      near As Double 'mines near to squares
    5. End Type
    6. Dim MySquare as square 'This creates ur variable
    7.      'You could also make an array eg Dim MySquare() as square
    8.  
    9. 'When u refer to it in future, u refer to the variable and not the
    10. 'type, so (say, in a button click evnt)
    11.  
    12. With Mysquare
    13.       .mine = True
    14.       .stay = 2
    15.       .near = 2
    16. End with
    17.  
    18. 'Also, i am not sure why ur stay and near internal variables are
    19. 'doubles as surely bytes would do the job.
    Regards
    stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2001
    Location
    Australia
    Posts
    14

    Thumbs up 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
  •  



Click Here to Expand Forum to Full Width