Visual Basic - Load Deck of Cards into an array
by Andy Flagg, Publication Date: Wednesday, July 22, 2020
View Count: 106, Keywords: Visual Basic, Deck of Cards, Hashtags: #VisualBasic #DeckofCards
I was just wanting to load a deck of cards into an array. nothing fancy.
Private Sub Form_Load()
Debug.Print "loading deck of cards"
'config suits and cards, decks and shoes this game will show me how to load a deck of cards and randomly pick one, then the next
'presume standard deck of cards, 4 suits, 13 cards per suit
'Ace through Jack, 10 through 2; ace, king, queen, jack, 10, 9, 8, 7, 6, 5, 4, 3, 2
'create the deck array and load it, and show it
z = 0
For x = 1 To 4
Select Case x 'select suit
suit = "H" 'hearts
suit = "D" 'diamonds
suit = "C" 'clubs
suit = "S" 'spades
For y = 14 To 2 Step -1
Select Case y
card = "A"
card = "K"
card = "Q"
card = "J"
card = y
'Debug.Print suit, card
deckofcards(z) = suit & card
z = z + 1
For x = 0 To 52
loading deck of cards
if you found this article helpful, consider contributing $10, 20 an Andrew Jackson or so..to the author. more authors coming soon
FYI we use paypal or patreon, patreon has 3x the transaction fees, so we don't, not yet.
© 2021 myBlog™ v1.1 All rights reserved. We count views as reads, so let's not over think it.