Results 1 to 3 of 3

Thread: [RESOLVED] when reseting the game should do i have to use redim

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Resolved [RESOLVED] when reseting the game should do i have to use redim

    this works good until i reset and reshuffle the cards.
    thanks

    Code:
    Public Sub Shuffle()
        Dim x As Integer, Y As Integer
        Dim isused(108) As Byte
        Dim ThisCard As Integer
        Dim test1 As Integer
        Dim totall As Integer
        Randomize
       If shuffled = False Then
           x = 1
           For x = 1 To 108
           Do
              ThisCard = Int((108 - 1 + 1) * Rnd + 1)
           Loop While isused(ThisCard) = 1
           'get and store
           pipVal(x) = ThisCard
           isused(ThisCard) = 1
             Next x
            shuffled = True
       End If
       ''''''''''''''''''''''''''''''''''''''''''''''''
       If numtimes = 0 Then
        '// make new hand tiles visible
        For x = 0 To 49
            player1(x).Visible = True
            Form2.player2(x).Visible = True
        Next x
           Y = 1
         For x = 0 To 14
           test1 = pipVal(Y)
          player1(x).Tag = CStr(cards(pipVal(Y)))
          CopyTile player1(x), test1, 2
           Y = Y + 1
         Next x
           Y = 16
         For x = 0 To 14
           test1 = pipVal(Y)
          Form2.player2(x).Tag = CStr(cards(pipVal(Y)))
          CopyTile Form2.player2(x), test1, 2 '//  draw tile back with a 1
          
           Y = Y + 1
         Next x
            Y = 31
          x = 0
           test1 = pipVal(Y)
          board(x).Tag = CStr(cards(pipVal(Y)))
          CopyTile board(x), test1, 2 '// draw tile back with a 1
           Y = Y + 1
         draw2 = Y
         shuffle1.Enabled = False
         numtimes = numtimes + 1
       End If
       Dim t As Integer
       Dim nt As Integer
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      If p1redthree = True Then
                   For t = 0 To 49
                      If player1(t).Tag = "" Then
                        x = t
                        Exit For
                      End If
                   Next t
                          If draw2 > 108 Then
                          draw1 = False
                          humanwentout = True
                                   If humanwentout = True Then
                                    Command1.Enabled = False
                                    Command3.Enabled = False
                                    Label41.Caption = "   HUMAN WENT OUT "
                                    ''''''put call to add up points here
                                         addimup
                                    Call clearall
                                    Call compcheckmeld
                                    Call humancheckmeld
                                            If Val(Label30.Caption) >= 6000 Then
                                                Label41.Caption = "       HUMAN WINS THE GAME  "
                                                Label30.Caption = "0"
                                                Label47.Caption = Val(Label47.Caption) + 1
                                                Label29.Caption = "0"
                                                Call clearall
                                            Else
                                                turn = False
                                                Shuffle
                                                frozendeck
                                                Label41.Caption = "       COMPUTERS                      TURN"
                                               
                                                Command1.Enabled = False
                                                Command3.Enabled = False
                                                computerturn
                                            End If
                                    
                                    End If
                          Exit Sub
                          End If
                          
                   test1 = pipVal(draw2)
                   player1(x).Tag = CStr(cards(pipVal(draw2)))
                   CopyTile player1(x), test1, 2
                   draw2 = draw2 + 1
         p1redthree = False
      End If
      If p2redthree = True Then
                   For t = 0 To 49
                      If Form2.player2(t).Tag = "" Then
                        x = t
                        Exit For
                      End If
                   Next t
                          If draw2 > 108 Then
                          draw1 = False
                          wentout = True
                                If wentout = True Then
                                Command1.Enabled = False
                                Command3.Enabled = False
                                Label41.Caption = "   COMPUTER WENT OUT "
                                ''''''put call to add up points here
                                addimup
                                Call clearall
                                Call compcheckmeld
                                Call humancheckmeld
                                        If Val(Label29.Caption) >= 6000 Then
                                            Label41.Caption = "       COMPUTER WIN THE GAME HE HE  "
                                            Label29.Caption = "0"
                                            Label45.Caption = Val(Label45.Caption) + 1
                                            Label30.Caption = "0"
                                            Call clearall
                                        Else
                                            turn = True
                                            Shuffle
                                            frozendeck
                                            Label41.Caption = "       HUMANS                        TURN"
                                            
                                            Command1.Enabled = True
                                            Command3.Enabled = True
                                        End If
                                 
                                End If
                          Exit Sub
                          End If
                         
                   test1 = pipVal(draw2)
                   Form2.player2(x).Tag = CStr(cards(pipVal(draw2)))
                   CopyTile Form2.player2(x), test1, 2
                   draw2 = draw2 + 1
         p2redthree = False
      End If
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''
     If draw1 = True Then
            If turn = True Then
                For nt = 0 To 1
                   For t = 0 To 49
                      If player1(t).Tag = "" Then
                        x = t
                        Exit For
                      End If
                   Next t
                          If draw2 > 108 Then
                          draw1 = False
                          humanwentout = True
                                   If humanwentout = True Then
                                    Command1.Enabled = False
                                    Command3.Enabled = False
                                    Label41.Caption = "   HUMAN WENT OUT "
                                    ''''''put call to add up points here
                                         addimup
                                    Call clearall
                                    Call compcheckmeld
                                    Call humancheckmeld
                                            If Val(Label30.Caption) >= 6000 Then
                                                Label41.Caption = "       HUMAN WINS THE GAME  "
                                                Label30.Caption = "0"
                                                Label47.Caption = Val(Label47.Caption) + 1
                                                Label29.Caption = "0"
                                                Call clearall
                                            Else
                                                turn = False
                                                Shuffle
                                                frozendeck
                                                Label41.Caption = "       COMPUTERS                      TURN"
                                                
                                                Command1.Enabled = False
                                                Command3.Enabled = False
                                                computerturn
                                            End If
                                     
                                    End If
                          Exit Sub
                          End If
                          If player1(x).Tag = "" Then
                                test1 = pipVal(draw2)
                                player1(x).Tag = CStr(cards(pipVal(draw2)))
                                CopyTile player1(x), test1, 2
                                draw2 = draw2 + 1
                          End If
                         
                Next nt
               turn = False
            Else
                For nt = 0 To 1
                    For t = 0 To 49
                        If Form2.player2(t).Tag = "" Then
                          x = t
                          Exit For
                        End If
                    Next t
                          If draw2 > 108 Then
                          draw1 = False
                          wentout = True
                                If wentout = True Then
                                Command1.Enabled = False
                                Command3.Enabled = False
                                Label41.Caption = "   COMPUTER WENT OUT "
                                ''''''put call to add up points here
                                addimup
                                Call clearall
                                Call compcheckmeld
                                Call humancheckmeld
                                        If Val(Label29.Caption) >= 6000 Then
                                            Label41.Caption = "       COMPUTER WIN THE GAME HE HE  "
                                            Label29.Caption = "0"
                                            Label45.Caption = Val(Label45.Caption) + 1
                                            Label30.Caption = "0"
                                            Call clearall
                                        Else
                                            turn = True
                                            Shuffle
                                            frozendeck
                                            Label41.Caption = "       HUMANS                        TURN"
                                            
                                            Command1.Enabled = True
                                            Command3.Enabled = True
                                        End If
                                
                                End If
                          Exit Sub
                          End If
                          If Form2.player2(x).Tag = "" Then
                                test1 = pipVal(draw2)
                                Form2.player2(x).Tag = CStr(cards(pipVal(draw2)))
                                CopyTile Form2.player2(x), test1, 2 '//  draw tile back with a 1
                                draw2 = draw2 + 1
                          End If
                      
                      
                 Next nt
               turn = True
            End If
              draw1 = False
      Else
      End If
     totall = 108
     totall = totall - draw2
     Label40.Caption = totall
    End Sub

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Re: when reseting the game should do i have to use redim

    i get the whole canasta game to work until the second or third hand then it deals me some of player2 cards

    im baffled

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Re: when reseting the game should do i have to use redim

    i finialy found it two words in another sub was wrong...weird

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width