Click here to Skip to main content
15,917,645 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Need Help with Shuffle of a deck Pin
Dave Kreskowiak10-Apr-09 7:11
mveDave Kreskowiak10-Apr-09 7:11 
GeneralRe: Need Help with Shuffle of a deck Pin
ymilan10-Apr-09 8:31
ymilan10-Apr-09 8:31 
AnswerRe: Need Help with Shuffle of a deck Pin
riced10-Apr-09 3:55
riced10-Apr-09 3:55 
GeneralRe: Need Help with Shuffle of a deck Pin
ymilan10-Apr-09 5:10
ymilan10-Apr-09 5:10 
GeneralRe: Need Help with Shuffle of a deck Pin
ymilan10-Apr-09 5:35
ymilan10-Apr-09 5:35 
GeneralRe: Need Help with Shuffle of a deck Pin
riced10-Apr-09 5:44
riced10-Apr-09 5:44 
GeneralRe: Need Help with Shuffle of a deck Pin
ymilan10-Apr-09 6:15
ymilan10-Apr-09 6:15 
GeneralRe: Need Help with Shuffle of a deck Pin
riced10-Apr-09 7:15
riced10-Apr-09 7:15 
I'm not sure why you need all the counters. Your Counter is always one less than Cardcount so is effectively redundant. In Do While Cardcount <= 52 And Counter < 53 both parts of the condition will have same logical value.

What is Image1() - it looks like an array but has a Visible property.
And this line implies that it is an array of integer: Image1(Cardcount) = CardVal

In any case here's a new version of the code that shuffles the images directly.
You would need to Dim tmpImage as an appropriate type.
To get a single random image after shuffling you could just use Image1(1) i.e. the top of the pack; or you could use tmpImage.

Private Sub Start_Click()
   Randomize

   'Dim tmpImage As ????
   Dim card1 As Integer
   Dim card2 As Integer
   Dim counter As Integer

   ' Shuffle the images - end value (100)
   Counter = 0
   Do While Counter <= 100
      ' Get two random image positions
      card1 = Int((52 * Rnd) + 1)
      card2 = Int((52 * Rnd) + 1)

      ' Swap images at these positions
      tmpImage      = Image1(card1)
      Image1(card1) = Image1(card2)
      Image1(card2) = tmpImage
   Loop

   ' Now output images in order
   counter = 1
   Do While counter <= 52
      Image1(counter).Visible = True
      counter = counter + 1
   Loop
End Sub

What version of VB are you using? I'd assumed VB.NET but I can't see where Image1() would fit in. But, IIRC, in VB6 there is an Image control (not used VB6 for about 5 years).

EDIT: forgot to Dim counter Smile | :)

Regards
David R

GeneralRe: Need Help with Shuffle of a deck Pin
ymilan10-Apr-09 8:34
ymilan10-Apr-09 8:34 
GeneralRe: Need Help with Shuffle of a deck Pin
riced10-Apr-09 8:50
riced10-Apr-09 8:50 
GeneralRe: Need Help with Shuffle of a deck Pin
ymilan10-Apr-09 8:46
ymilan10-Apr-09 8:46 
GeneralRe: Need Help with Shuffle of a deck Pin
riced10-Apr-09 8:58
riced10-Apr-09 8:58 
GeneralRe: Need Help with Shuffle of a deck Pin
ymilan10-Apr-09 8:59
ymilan10-Apr-09 8:59 
GeneralRe: Need Help with Shuffle of a deck Pin
riced10-Apr-09 9:14
riced10-Apr-09 9:14 
GeneralRe: Need Help with Shuffle of a deck Pin
ymilan10-Apr-09 9:41
ymilan10-Apr-09 9:41 
GeneralRe: Need Help with Shuffle of a deck Pin
ymilan10-Apr-09 9:43
ymilan10-Apr-09 9:43 
GeneralRe: Need Help with Shuffle of a deck Pin
riced10-Apr-09 10:03
riced10-Apr-09 10:03 
GeneralRe: Need Help with Shuffle of a deck Pin
ymilan10-Apr-09 10:22
ymilan10-Apr-09 10:22 
GeneralRe: Need Help with Shuffle of a deck Pin
riced10-Apr-09 10:54
riced10-Apr-09 10:54 
GeneralRe: Need Help with Shuffle of a deck Pin
ymilan10-Apr-09 10:58
ymilan10-Apr-09 10:58 
GeneralRe: Need Help with Shuffle of a deck Pin
riced10-Apr-09 11:08
riced10-Apr-09 11:08 
GeneralRe: Need Help with Shuffle of a deck Pin
ymilan11-Apr-09 6:13
ymilan11-Apr-09 6:13 
GeneralRe: Need Help with Shuffle of a deck Pin
riced12-Apr-09 3:50
riced12-Apr-09 3:50 
GeneralRe: Need Help with Shuffle of a deck Pin
ymilan12-Apr-09 5:58
ymilan12-Apr-09 5:58 
GeneralRe: Need Help with Shuffle of a deck Pin
riced12-Apr-09 6:29
riced12-Apr-09 6:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.