Results 1 to 5 of 5

Thread: Blackjack

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    8

    Blackjack

    hello all i am new to this forum but a big hello goes to you all!. Currently i am making a blackjack game with vb 6.0. My skills are pretty limited but this is my question

    Currently i have 52 card images.
    have decided to break them into two sets

    first set : card suit

    second set : cards and values

    the question is

    How do i get the computer to ranbdomly select a card, and give its value, display the card and total the cards the program is set up i just need a hand with getting the algorithms in there

  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Do you know anything about objects? Or UDT?

    The best way would probably be to gather all the cards in an array of objects or UDT and then use a Rnd function to pick one of them.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    8
    not really ....like i said im pretty new,,,have dealt with arrays in the past though if possible could you excplain in detail

  4. #4
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I am on my way to bed right now. But I have time for a short explenation.

    You can make an UDT like this:

    VB Code:
    1. Private Type CardType
    2.     color As Long       '1 = spade, 2=heart and so on
    3.     number As Long    '1-13??
    4. End Type


    THen you can make an array of them like this

    VB Code:
    1. Dim Card(51) As CardType

    Then you can say that :

    VB Code:
    1. Card(0).color = 1
    2. Card(0).nuber = 1

    If you do this in a double loop you can tell all of the "cards" in the array what number and color they are.

    Then you can use a Rnd (do a search if you don't know what it is) and bick one of the 52 elements in the array.

    Hope that at least helped a little bi.


    Good night.
    ØØ

  5. #5
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    You could put all the cards in an array and swap them around for so many times to shuffle the deck. Then just pick the top card from the deck (i.e the next position in your array.)

    If you are randomly picking from an array, you have a chance of picking the same card twice.
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

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