Results 1 to 4 of 4

Thread: Problem: Randomize and Count

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    3

    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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    3

    Re: Problem: Randomize and Count

    Quote 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

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    3

    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
  •  



Click Here to Expand Forum to Full Width