|
-
May 24th, 2007, 03:44 AM
#1
Thread Starter
New Member
Problem: Randomize and Count
Hi Everybody. I am trying to make a Black Jack program which can randomize numbers witin a specific range and then count them and stop if a certain value are reached. So If I randomizes and gets 7, 8 and 10 a function counts that 7 + 8 = 15 and 15 + 10 = 25.
25 would be too much so it then states that the game is over via a If AddACard <= 21 GameOver. But I'm not really there yet. I'm stuck at the part where the counter should count the randomized numbers.
I've tried with different ways but it never works, it just attaches to the randomizer and dynamically change every time the randomizer calls a number or randomizes two numbers every time the randomizer does one number.
I have One button and two labels. The button randomizes(draws a card) a number, and Label1 displays it. Label2 Is meant to serve as a counter and display the cards you've drawn and add them.
This is the Randomize Function.
Code:
Function GetACard() As Integer
Randomize
GetACard = Int(14 * Rnd + 1)
End Function
Here's button one.
Code:
Private Sub Command1_Click()
GetACard ' Calls the Randomize Function.
Label1.Caption = GetACard ' Puts Randomized Number in Label1
AddACard ' This is where the problem starts.
End Sub
Code:
Function AddACard() As Integer ' This doesn't seem to Work. Seems to Randomize two numbers.
AddACard = GetACard
AddACard = AddACard + GetACard
Label2.Caption = GetACard
End Function
Does anyone have a clue how to make it add the numbers and store them?
Thanks in Advance!
Mike
-
May 24th, 2007, 09:50 AM
#2
Re: Problem: Randomize and Count
Moved to Games and Graphics
Welcome to the Forums. 
Have a look at this submission by Martin Liss in our Games CodeBank section.
-
May 24th, 2007, 03:57 PM
#3
Thread Starter
New Member
Re: Problem: Randomize and Count
 Originally Posted by Hack
Moved to Games and Graphics
Welcome to the Forums.
Have a look at this submission by Martin Liss in our Games CodeBank section.
Thanks, this seems to be a great community!
Martin Liss's BlackJack seems interesting .
Will take a close look.
Thanks for the help!
Mikael
-
May 24th, 2007, 04:39 PM
#4
Thread Starter
New Member
Re: Problem: Randomize and Count
The Issue is now solved. I added a Form_Load statement which set a variable to 0 which made it start to count from 0 + each card drawn.
Thanks for Help,
Mikael
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
|