|
-
Apr 8th, 2002, 06:08 PM
#1
Thread Starter
Fanatic Member
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?
-
Apr 8th, 2002, 06:36 PM
#2
This should get you started
VB Code:
Private Sub Command1_Click()
Dim MyNumber As Long
Randomize
MyNumber = (50 * Rnd) + 1
Select Case MyNumber
Case 0 To 4
'display $250.00 card
Case 5 To 9
'display $500.00 card
Case 10 To 15 'you code from here
Case 40 To 44
'bust card
Case 45 To 48
'another bust card
Case 50
'winner
End Select
'question: what happened to 49?
End Sub
-
Apr 8th, 2002, 08:25 PM
#3
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|