make a deck of cards?

how to make a deck of cards using visual basic 6

Page 1 of 1

2 Replies - 4021 Views - Last Post: 22 February 2009 - 11:32 PM Rate Topic: -----

#1 mrunner4home  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 16-February 09

make a deck of cards?

Posted 22 February 2009 - 09:02 AM

i'm making a program that plays cards. i already have the images of all the cards (imgCard(0-51)) and an image for the top of the deck (imgRndCard...i was thinking of clicking on this card to make the next card go face-up to the discard pile)

the program will EVENTUALLY play the simple game of Hi-Lo (for a science project). the only thing i need help with is i don't know how to get a deck of cards to work. i am kind of a beginner at programming.

it is visual basic 6 programming

all i need right now is for when i click on the top of a deck of cards (the imgRndCard) for the next card in the deck to show in the discard pile. or i don't even mind a command or something, actually, just something to make the deck work.

i already have the code to make the deck random, so please answer with accordance to this code (and ... will this code work? for letting me go through the entire deck then it shuffles and lets me go through again? basically, having it shuffle and stuff correctly?):


'suit order is spades, clubs, hearts, diamonds
'discard pile: top = 480, left = 2520
Dim arrDeck(0 To 51) As Integer

Public Sub ShuffleDeck()
Randomize 'Makes it so the starting seed is different
Dim CardCount As Integer 'This will be my loop counter
Dim CardVal As Integer 'This will get assigned the random value

CardCount = 1 'Resets card count to 1

Do While CardCount < 52 'This sets every slot in arrDeck to -1
arrDeck(CardCount) = -1 'so that later I can tell if the slot is empty
CardCount = CardCount + 1 'or not
Loop

CardCount = 1 'Resets card count to 1

Do While CardCount < 52 'Loop until every slot is full
10 CardVal = Int((51 * Rnd) + 1) 'Set CardVal = to a random number
If arrDeck(CardVal) = -1 Then 'Take random slot and see if there is a card
'in it yet. If there isn't it will be = to -1
'if there is it will be equal to a different
'value.
arrDeck(CardVal) = CardCount 'There isn't so put current card in that slot
CardCount = CardCount + 1 'Increment my card count

Else: GoTo 10 'There is so start again from the beginning
End If
Loop 'Do it all again if < 52
End Sub




if the code doesn't work then how can i make it work? how do i make this deck of cards work correctly? well, thank you in advance

Is This A Good Question/Topic? 0
  • +

Replies To: make a deck of cards?

#2 luigiplumbersinc  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 82
  • Joined: 16-February 09

Re: make a deck of cards?

Posted 22 February 2009 - 07:09 PM

hey man i'm real sorry i havent gotten the example code i said i'd give you last few days i've been sick... and dead... i went the movies and brought a notepad so i could write the code while i was there but they dimmed the lights and i couldnt see lol hopefully will finish enough of it soon

Goodluck! :D
Was This Post Helpful? 0
  • +
  • -

#3 luigiplumbersinc  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 82
  • Joined: 16-February 09

Re: make a deck of cards?

Posted 22 February 2009 - 11:32 PM

removed. please see the newer topic

This post has been edited by luigiplumbersinc: 23 February 2009 - 10:20 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1