# confused over something simple

I got bored so I decided to make a blackjack game... it turned out to be more frustrating than anything else... I want to determine what card gets put down where...

Randomize
Do
intPlayer2 = Int((52 * Rnd) + 1)
Loop Until (intPlayer2 <> intPlayer1 Or intDealer2 Or intDealer1)

unfortunately what is happening is I get one of the dealers cards that appears both in his hand and my own. I dont want this, so i figured id put the code above in and try to see if I could fix it by preventing the random number from being drawn twice. It still occurs. Could anyone tell me whats wrong (i dont know if maybe i didnt put the parenthesis in the right place or what) the rest of the code seems to be fine and the dealers first two cards are never the same (i ran it about 100 times to check).

• : I got bored so I decided to make a blackjack game... it turned out to be more frustrating than anything else... I want to determine what card gets put down where...
:
: Randomize
: Do
: intPlayer2 = Int((52 * Rnd) + 1)
: Loop Until (intPlayer2 <> intPlayer1 Or intDealer2 Or intDealer1)
:
: unfortunately what is happening is I get one of the dealers cards that appears both in his hand and my own. I dont want this, so i figured id put the code above in and try to see if I could fix it by preventing the random number from being drawn twice. It still occurs. Could anyone tell me whats wrong (i dont know if maybe i didnt put the parenthesis in the right place or what) the rest of the code seems to be fine and the dealers first two cards are never the same (i ran it about 100 times to check).
:

Loop Until (intPlayer2 <> (intPlayer1 Or intDealer2 Or intDealer1))

That way all of the conditions are tested.

Though it might be better like>>

Loop Until (intPlayer2 <> intPlayer1 Or intPlayer2<>intDealer2 Or intPlayer2<>intDealer1)

Alternatively chack for which of the 52 cards are drawn each time using an array of 1's and o's for example>>

In standard basic>>

Dim Card(52)

Rem Fill the array with noughts.
For a=1 to 52
Card(a)=0
Next a

Rem In the next FOR-NEXT loop the array Card(52) will be filled with 1's for the number of cards you wish to draw. Don't forget to set the array to o's for the next deal.

For Deal=1 to NumberOfCards

Repeat
R=(Rnd(1)*52)+1
Until Card(R)<>1
Card(R)=1

Next Deal

I hope this helps. :-)

:
: Loop Until (intPlayer2 <> (intPlayer1 Or intDealer2 Or intDealer1))
:
:
: That way all of the conditions are tested.
:
: Though it might be better like>>
:
: Loop Until (intPlayer2 <> intPlayer1 Or intPlayer2<>intDealer2 Or intPlayer2<>intDealer1)
:
: Alternatively chack for which of the 52 cards are drawn each time using an array of 1's and o's for example>>
:
: In standard basic>>
:
: Dim Card(52)
:
: Rem Fill the array with noughts.
: For a=1 to 52
: Card(a)=0
: Next a
:
: Rem In the next FOR-NEXT loop the array Card(52) will be filled with 1's for the number of cards you wish to draw. Don't forget to set the array to o's for the next deal.
:
: For Deal=1 to NumberOfCards
:
: Repeat
: R=(Rnd(1)*52)+1
: Until Card(R)<>1
: Card(R)=1
:
: Next Deal
:
: I hope this helps. :-)
:

Surprisingly it didnt do anything different. I zipped the form and all requirements and posted it on ewilkins.travisbsd.org (personal site). Ive checked everything there but cant seem to figure out what it is... maybe i overlooked something? (I did not try your array suggestion, because Ive never used arrays before and its already frustrating me enough ) I usually can figure most things out on my own but this time im having no luck at all. The code is really a mess.