Results 1 to 3 of 3

Thread: I need this for a game I'm writing.

  1. #1

    Thread Starter
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692

    I need this for a game I'm writing.

    I intend to sort integers into different "cards," each "card" representing an image to be displayed inside a picture box. I want the following:

    If the random number is between 0 and 4, display a $250 "money card"

    If the random number is between 5 and 9, display a $500 "money card"

    And so on... all the way to 40, then I want this:

    If the random number is between 40 and 44, display a bust card.

    If the random integer is between 45 and 48, display a bust other card.

    If the random integer equals 50, display the winner card.

    How would I convert this to code?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    This should get you started
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim MyNumber As Long
    3. Randomize
    4. MyNumber = (50 * Rnd) + 1
    5. Select Case MyNumber
    6.    Case 0 To 4
    7.     'display $250.00 card
    8.    Case 5 To 9
    9.     'display $500.00 card
    10.    Case 10 To 15 'you code from here
    11.    Case 40 To 44
    12.     'bust card
    13.    Case 45 To 48
    14.     'another bust card
    15.    Case 50
    16.     'winner
    17. End Select
    18. 'question:  what happened to 49?
    19. End Sub

  3. #3

    Thread Starter
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692
    Sorry about that

    50 is 49... I just goofed up while I was typing... there are 50 variables, but I just used the default definition. Instead of index 1 to 50, I used index 0 to 49, I find it much easier that way because of the "Subscript out of range" messages I get when I use Option Base 1 and the index 1 to 50. Thanks for your help.

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