Signature (Visual Basic / VBA)
Public Function DealPlayingCardDecks( _
ByRef rDeck() As Variant _
, Optional ByVal vNumDecks As Variant _
, Optional ByVal vUseJokers As Variant _
) As Boolean
Code Examples
Assuming
Dim avarDeck() As Variant
Rnd(-1) = 0.224007
for example
DealPlayingCardDecks(avarDeck(), 1, False) = True
leaves
LBound(avarDeck) = 0
UBound(avarDeck) = 52
IsEmpty(avarDeck(0)) = True
avarDeck(1) = "KC"
avarDeck(2) = "2D"
...
avarDeck(51) = "7C"
avarDeck(52) = "7A"
1 Joker
2..10 Numbered cards 2 through 10
J Jack
Q Queen
K King
A Ace
A Aces
C Clubs
D Diamonds
S Spades
Parameters
| Parameter | Description |
|---|---|
| rDeck | A dynamic array of Variant values into which the deck(s) of cards will be dealt. Function will always reinitialize this array, even if it otherwise has a problem and returns False. |
| vNumDecks | The number of decks of playing cards which are to be dealt. vNumDecks defaults to 1 (one) if it is missing or Null or cannot be fixed up to a number. Function does nothing and returns False if vNumDecks is not between 1 (one) and 8 (eight). |
| vUseJokers | Determines whether two Joker cards will be dealt along with each deck. vUseJokers defaults to False if it is missing or Null or cannot be fixed up to a number. |
Return Value
Function returns True upon success and False upon failure.
Notes & Version History
| Note | The call to the Visual Basic Rnd function in the above example seeds the Visual Basic random number generator so that the sample results can be reproduced. There is generally no need to call the Rnd function within your programs since Entisoft Tools initializes the Visual Basic random number generator once with "Randomize" statement. |
| Summary | Each card is represented by a two- or three-character string that describes the number of the card and its suite. The card abbreviation is composed of one value from each of the following tables: |
| Card Suites | When Jokers are used, this function and DealPlayingCardDecks only recognize Jokers as belonging to the Aces and Clubs suites. |
| Note | This function starts out with the cards in order, then it shuffles each card three times. |