Question Interference between 2 arrays

Joined
Oct 27, 2008
Messages
5
Location
Puerto Rico
Programming Experience
3-5
Hello.

I'm having problems with 2 2-dimensional arrays. Whenever I change the value in a cell in one of them, the value of cell with the same indices changes in the other one.

VB.NET:
Imports System.IO
Imports System.Threading
Imports System.Drawing.Imaging
Imports System.Drawing



Public Class Form1
    Dim black_path As String = "black_piece.bmp"
    Dim red_path As String = "red_piece.bmp"
    Dim black_king_path As String = "black_king.bmp"
    Dim red_king_path As String = "red_king.bmp"
    Dim board(0 To 7, 0 To 7) As Char
    'Dim temp_board(0 To 7, 0 To 7) As Char

    Dim buttons(0 To 7, 0 To 7) As Button
    Dim piece_color As Char
    Dim temp_image As Image
    Dim temp_piece As Char
    Dim temp_row, temp_col As Integer
    Dim turn As Integer
    Dim selected As Boolean
    Dim darkblue As Color = Color.DarkBlue
    Dim seagreen As Color = Color.MediumSeaGreen
    Dim dificulty = 1
    Class play
        Public eval As Integer
        Public board_play(0 To 7, 0 To 7) As Char
        Public move_from(0 To 1) As Integer
        Public move_to(0 To 1) As Integer
        Public children() As play
    End Class


    Function print()
        ListBox1.Items.Clear()
        For i = 0 To 7
            ListBox1.Items.Add(board(i, 0).ToString() & " " & board(i, 1).ToString() & " " & board(i, 2).ToString() & " " & board(i, 3).ToString() & " " & board(i, 4).ToString() & " " & board(i, 5).ToString() & " " & board(i, 6).ToString() & " " & board(i, 7).ToString())
        Next
    End Function

    Function a_print(ByVal play_board As Char(,))
        ListBox1.Items.Add("--------------------------")
        For i = 0 To 7
            ListBox1.Items.Add(play_board(i, 0).ToString() & " " & play_board(i, 1).ToString() & " " & play_board(i, 2).ToString() & " " & play_board(i, 3).ToString() & " " & play_board(i, 4).ToString() & " " & play_board(i, 5).ToString() & " " & play_board(i, 6).ToString() & " " & play_board(i, 7).ToString())
        Next
    End Function
    Function a_print2(ByVal play_board As Char(,))
        ListBox2.Items.Add("--------------------------")
        For i = 0 To 7
            ListBox2.Items.Add(play_board(i, 0).ToString() & " " & play_board(i, 1).ToString() & " " & play_board(i, 2).ToString() & " " & play_board(i, 3).ToString() & " " & play_board(i, 4).ToString() & " " & play_board(i, 5).ToString() & " " & play_board(i, 6).ToString() & " " & play_board(i, 7).ToString())
        Next
    End Function

    Private Sub Form1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Click
        no_highlight()
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For i = 1 To 8
            board(0, i) = "b"
            board(0, i - 1) = "W"
            board(1, i - 1) = "b"
            board(1, i) = "W"
            board(2, i) = "b"
            board(2, i - 1) = "W"
            board(3, i - 1) = "O"
            board(3, i) = "W"
            board(4, i - 1) = "W"
            board(4, i) = "O"
            board(5, i - 1) = "r"
            board(5, i) = "W"
            board(6, i) = "r"
            board(6, i - 1) = "W"
            board(7, i - 1) = "r"
            board(7, i) = "W"
            i = i + 1
        Next
        'print()
        init_button_array()

    End Sub
    Function highlight(ByVal row As Integer, ByVal col As Integer) As Nullable
        If board(row, col) = "R" Then 'If it's a queen
            If row < 7 Then
                If col < 7 Then 'Move Down 'MD
                    If board(row + 1, col + 1) = "O" Then
                        buttons(row + 1, col + 1).BackColor = darkblue
                    ElseIf row < 6 And col < 6 And board(row + 1, col + 1) = "b" Then
                        If board(row + 2, col + 2) = "O" Then
                            buttons(row + 2, col + 2).BackColor = darkblue 'Highlight Jump
                            board(row + 2, col + 2) = "V"
                        End If
                    End If
                End If
                If col > 0 Then                         'B
                    If board(row + 1, col - 1) = "O" Then    'A
                        buttons(row + 1, col - 1).BackColor = darkblue
                    ElseIf row < 6 And col > 1 And board(row + 1, col - 1) = "b" Then
                        If board(row + 2, col - 2) = "O" Then
                            buttons(row + 2, col - 2).BackColor = darkblue 'Highlight Jump
                            board(row + 2, col - 2) = "V"
                        End If
                    End If                                  'A                                  'B
                End If   'MD
                If row > 0 Then
                    If col < 7 Then 'Move Up
                        If board(row - 1, col + 1) = "O" Then   'A
                            buttons(row - 1, col + 1).BackColor = darkblue
                        ElseIf row > 1 And col < 6 And board(row - 1, col + 1) = "b" Then
                            If board(row - 2, col + 2) = "O" Then
                                buttons(row - 2, col + 2).BackColor = darkblue 'Highlight Jump
                                board(row - 2, col + 2) = "V"
                            End If
                        End If                                  'A
                    End If
                    If col > 0 Then
                        If board(row - 1, col - 1) = "O" Then   'A
                            buttons(row - 1, col - 1).BackColor = darkblue
                        ElseIf row > 1 And col > 1 And board(row - 1, col - 1) = "b" Then
                            If board(row - 2, col - 2) = "O" Then
                                buttons(row - 2, col - 2).BackColor = darkblue 'Highlight Jump
                                board(row - 2, col - 2) = "V"
                            End If
                        End If                                  'A
                    End If
                End If

            End If
        Else  'If it's a normal red piece, only highlight forward.
            If row > 0 Then                         'C
                If col < 7 Then                         'B
                    If board(row - 1, col + 1) = "O" Then   'A
                        buttons(row - 1, col + 1).BackColor = darkblue
                    ElseIf col < 6 And row > 1 And board(row - 1, col + 1) = "b" Then
                        If board(row - 2, col + 2) = "O" Then
                            buttons(row - 2, col + 2).BackColor = darkblue 'Highlight Jump
                            board(row - 2, col + 2) = "V"
                        End If
                    End If                                  'A
                End If                                  'B

                If col > 0 Then                         'B
                    If board(row - 1, col - 1) = "O" Then   'A
                        buttons(row - 1, col - 1).BackColor = darkblue
                    ElseIf col > 1 And row > 1 And board(row - 1, col - 1) = "b" Then
                        If board(row - 2, col - 2) = "O" Then
                            buttons(row - 2, col - 2).BackColor = darkblue 'Highlight Jump
                            board(row - 2, col - 2) = "V"
                        End If
                    End If                                  'A
                End If                                  'B
            End If                                  'C
        End If
    End Function
    Function no_highlight() As Nullable
        For i = 0 To 7
            For j = 0 To 7
                If board(i, j) = "O" OrElse board(i, j) = "V" OrElse board(i, j) = "C" OrElse board(i, j) = "M" Then
                    buttons(i, j).BackColor = seagreen
                End If
            Next
        Next
    End Function
    Function no_highlight(ByRef board2(,) As Char) As Nullable
        For i = 0 To 7
            For j = 0 To 7
                If board2(i, j) = "O" OrElse board2(i, j) = "V" OrElse board2(i, j) = "C" OrElse board2(i, j) = "M" Then
                    buttons(i, j).BackColor = seagreen
                End If
            Next
        Next
    End Function
    Function clear_V() As Nullable
        For i = 0 To 7
            For j = 0 To 7
                If board(i, j) = "V" OrElse board(i, j) = "M" OrElse board(i, j) = "C" Then
                    board(i, j) = "O"
                End If
            Next
        Next
    End Function
    Function eat(ByVal x As Integer, ByVal y As Integer) As Nullable
        If temp_row - x = 2 And temp_col - y = 2 Then
            board(x + 1, y + 1) = "O"
            buttons(x + 1, y + 1).BackgroundImage = Nothing
        ElseIf temp_row - x = 2 And temp_col - y = -2 Then
            board(x + 1, y - 1) = "O"
            buttons(x + 1, y - 1).BackgroundImage = Nothing
        ElseIf temp_row - x = -2 And temp_col - y = 2 Then
            board(x - 1, y + 1) = "O"
            buttons(x - 1, y + 1).BackgroundImage = Nothing
        ElseIf temp_row - x = -2 And temp_col - y = -2 Then
            board(x - 1, y - 1) = "O"
            buttons(x - 1, y - 1).BackgroundImage = Nothing
        End If
    End Function
    Function init_button_array() As Nullable
        'Link the buttons the with button array
        buttons(0, 0) = b00
        buttons(0, 1) = b01
        buttons(0, 2) = b02
        buttons(0, 3) = b03
        buttons(0, 4) = b04
        buttons(0, 5) = b05
        buttons(0, 6) = b06
        buttons(0, 7) = b07

        buttons(1, 0) = b10
        buttons(1, 1) = b11
        buttons(1, 2) = b12
        buttons(1, 3) = b13
        buttons(1, 4) = b14
        buttons(1, 5) = b15
        buttons(1, 6) = b16
        buttons(1, 7) = b17

        buttons(2, 0) = b20
        buttons(2, 1) = b21
        buttons(2, 2) = b22
        buttons(2, 3) = b23
        buttons(2, 4) = b24
        buttons(2, 5) = b25
        buttons(2, 6) = b26
        buttons(2, 7) = b27

        buttons(3, 0) = b30
        buttons(3, 1) = b31
        buttons(3, 2) = b32
        buttons(3, 3) = b33
        buttons(3, 4) = b34
        buttons(3, 5) = b35
        buttons(3, 6) = b36
        buttons(3, 7) = b37

        buttons(4, 0) = b40
        buttons(4, 1) = b41
        buttons(4, 2) = b42
        buttons(4, 3) = b43
        buttons(4, 4) = b44
        buttons(4, 5) = b45
        buttons(4, 6) = b46
        buttons(4, 7) = b47

        buttons(5, 0) = b50
        buttons(5, 1) = b51
        buttons(5, 2) = b52
        buttons(5, 3) = b53
        buttons(5, 4) = b54
        buttons(5, 5) = b55
        buttons(5, 6) = b56
        buttons(5, 7) = b57

        buttons(6, 0) = b60
        buttons(6, 1) = b61
        buttons(6, 2) = b62
        buttons(6, 3) = b63
        buttons(6, 4) = b64
        buttons(6, 5) = b65
        buttons(6, 6) = b66
        buttons(6, 7) = b67

        buttons(7, 0) = b70
        buttons(7, 1) = b71
        buttons(7, 2) = b72
        buttons(7, 3) = b73
        buttons(7, 4) = b74
        buttons(7, 5) = b75
        buttons(7, 6) = b76
        buttons(7, 7) = b77
    End Function
    Function eval_funct(ByRef play_board As Char(,)) As Integer
        Dim evaluation As Integer
        For i = 0 To 7
            For j = 0 To 7
                If play_board(i, j) = "b" Then
                    evaluation = evaluation + 1
                ElseIf play_board(i, j) = "C" Then
                    evaluation = evaluation + 3
                ElseIf play_board(i, j) = "B" Then
                    evaluation = evaluation + 2
                ElseIf play_board(i, j) = "r" Then
                    evaluation = evaluation - 1
                ElseIf play_board(i, j) = "B" Then
                    evaluation = evaluation - 2
                ElseIf play_board(i, j) = "V" Then
                    evaluation = evaluation - 3
                End If
            Next
        Next
        Return evaluation
    End Function
    Function mark_red(ByVal row As Integer, ByVal col As Integer)
        If board(row, col) = "R" Then 'If it's a queen
            If row < 7 Then
                If col < 7 Then 'Move Down 'MD
                    If board(row + 1, col + 1) = "O" Then
                        buttons(row + 1, col + 1).BackColor = darkblue
                    ElseIf row < 6 And col < 6 And board(row + 1, col + 1) = "b" Then
                        If board(row + 2, col + 2) = "O" Then
                            buttons(row + 2, col + 2).BackColor = darkblue 'Highlight Jump
                            board(row + 2, col + 2) = "V"
                        End If
                    End If
                End If
                If col > 0 Then                         'B
                    If board(row + 1, col - 1) = "O" Then    'A
                        buttons(row + 1, col - 1).BackColor = darkblue
                    ElseIf row < 6 And col > 1 And board(row + 1, col - 1) = "b" Then
                        If board(row + 2, col - 2) = "O" Then
                            buttons(row + 2, col - 2).BackColor = darkblue 'Highlight Jump
                            board(row + 2, col - 2) = "V"
                        End If
                    End If                                  'A                                  'B
                End If   'MD
                If row > 0 Then
                    If col < 7 Then 'Move Up
                        If board(row - 1, col + 1) = "O" Then   'A
                            buttons(row - 1, col + 1).BackColor = darkblue
                        ElseIf row > 1 And col < 6 And board(row - 1, col + 1) = "b" Then
                            If board(row - 2, col + 2) = "O" Then
                                buttons(row - 2, col + 2).BackColor = darkblue 'Highlight Jump
                                board(row - 2, col + 2) = "V"
                            End If
                        End If                                  'A
                    End If
                    If col > 0 Then
                        If board(row - 1, col - 1) = "O" Then   'A
                            buttons(row - 1, col - 1).BackColor = darkblue
                        ElseIf row > 1 And col > 1 And board(row - 1, col - 1) = "b" Then
                            If board(row - 2, col - 2) = "O" Then
                                buttons(row - 2, col - 2).BackColor = darkblue 'Highlight Jump
                                board(row - 2, col - 2) = "V"
                            End If
                        End If                                  'A
                    End If
                End If

            End If
        Else  'If it's a normal red piece, only highlight forward.
            If row > 0 Then                         'C
                If col < 7 Then                         'B
                    If board(row - 1, col + 1) = "O" Then   'A
                        buttons(row - 1, col + 1).BackColor = darkblue
                    ElseIf col < 6 And row > 1 And board(row - 1, col + 1) = "b" Then
                        If board(row - 2, col + 2) = "O" Then
                            buttons(row - 2, col + 2).BackColor = darkblue 'Highlight Jump
                            board(row - 2, col + 2) = "V"
                        End If
                    End If                                  'A
                End If                                  'B

                If col > 0 Then                         'B
                    If board(row - 1, col - 1) = "O" Then   'A
                        buttons(row - 1, col - 1).BackColor = darkblue
                    ElseIf col > 1 And row > 1 And board(row - 1, col - 1) = "b" Then
                        If board(row - 2, col - 2) = "O" Then
                            buttons(row - 2, col - 2).BackColor = darkblue 'Highlight Jump
                            board(row - 2, col - 2) = "V"
                        End If
                    End If                                  'A
                End If                                  'B
            End If                                  'C
        End If
    End Function
   
    Function mark_black(ByVal temp_board(,) As Char, ByVal row As Integer, ByVal col As Integer) As Integer
        If temp_board(row, col) = "B" Then 'If it's a queen
            If row < 7 Then
                If col < 7 Then 'Move Down 'MD
                    If temp_board(row + 1, col + 1) = "O" Then
                        temp_board(row + 1, col + 1) = "M"
                        temp_row = row + 1
                        temp_col = col + 1
                    ElseIf row < 6 And col < 6 And temp_board(row + 1, col + 1) = "r" Then
                        If temp_board(row + 2, col + 2) = "O" Then
                            temp_board(row + 2, col + 2) = "C"
                            temp_row = row + 2
                            temp_col = col + 2
                        End If
                    End If
                End If
                If col > 0 Then                         'B
                    If temp_board(row + 1, col - 1) = "O" Then    'A
                        temp_board(row + 1, col - 1) = "M"
                        temp_row = row + 1
                        temp_col = col - 1
                    ElseIf row < 6 And col > 1 And temp_board(row + 1, col - 1) = "r" Then
                        If temp_board(row + 2, col - 2) = "O" Then
                            temp_board(row + 2, col - 2) = "C"
                            temp_row = row + 2
                            temp_col = col - 2
                        End If
                    End If                                  'A                                  'B
                End If   'MD
                If row > 0 Then
                    If col < 7 Then 'Move Up
                        If temp_board(row - 1, col + 1) = "O" Then   'A
                            temp_board(row - 1, col + 1) = "M"
                            temp_row = row - 1
                            temp_col = col + 1
                        ElseIf row > 1 And col < 6 And temp_board(row - 1, col + 1) = "b" Then
                            If temp_board(row - 2, col + 2) = "O" Then
                                temp_board(row - 2, col + 2) = "C"
                                temp_row = row - 2
                                temp_col = col + 2
                            End If
                        End If                                  'A
                    End If
                    If col > 0 Then
                        If temp_board(row - 1, col - 1) = "O" Then   'A
                            temp_board(row - 1, col - 1) = "M"
                            temp_row = row - 1
                            temp_col = col - 1
                        ElseIf row > 1 And col > 1 And temp_board(row - 1, col - 1) = "r" Then
                            If temp_board(row - 2, col - 2) = "O" Then
                                temp_board(row - 2, col - 2) = "C"
                                temp_row = row - 2
                                temp_col = col - 2
                            End If
                        End If                                  'A
                    End If
                End If

            End If
        Else  'If it's a normal black piece, only highlight forward.
            If row > 0 Then                         'C
                If col < 7 Then                         'B
                    If temp_board(row + 1, col + 1) = "O" Then   'A
                        temp_board(row + 1, col + 1) = "M"
                        temp_row = row + 1
                        temp_col = col + 1
                    ElseIf col < 6 And row > 1 And temp_board(row + 1, col + 1) = "r" Then
                        If temp_board(row + 2, col + 2) = "O" Then
                            temp_board(row + 2, col + 2) = "C"
                            temp_row = row + 2
                            temp_col = col + 2
                        End If
                    End If                                  'A
                End If                                  'B

                If col > 0 Then                         'B
                    If temp_board(row + 1, col - 1) = "O" Then   'A
                        temp_board(row + 1, col - 1) = "M"
                        temp_row = row + 1
                        temp_col = col - 1
                    ElseIf col > 1 And row > 1 And temp_board(row + 1, col - 1) = "r" Then
                        If temp_board(row + 2, col - 2) = "O" Then
                            temp_board(row + 2, col - 2) = "C"
                            temp_row = row + 2
                            temp_col = col - 2
                        End If
                    End If                                  'A
                End If                                  'B
            End If                                  'C
        End If
        'mark_red(row, col)
    End Function

    Function play_black(ByRef play_board(,) As Char, ByVal row As Integer, ByVal col As Integer, ByVal new_row As Integer, ByVal new_col As Integer)
        play_board(row, col) = "O"
        play_board(new_row, new_col) = "b"
        no_highlight(play_board)

        For i = 0 To 7
            For j = 0 To 7
                If play_board(i, j) = "M" OrElse play_board(i, j) = "C" Then
                    play_board(i, j) = "O"
                End If
            Next
        Next
        a_print2(play_board)
        ListBox2.Items.Add("######################")
    End Function

    Function play_black_king(ByRef a_play As play, ByVal row As Integer, ByVal col As Integer, ByVal new_row As Integer, ByVal new_col As Integer)
        a_play.board_play(row, col) = "O"
        a_play.board_play(new_row, new_col) = "B"

        If new_row - row = 2 And new_col - col = 2 Then
            board(row + 1, col + 1) = "O"
            buttons(row + 1, col + 1).BackgroundImage = Nothing
        ElseIf new_row - row = 2 And new_col - col = -2 Then
            board(row + 1, col - 1) = "O"
            buttons(row + 1, col - 1).BackgroundImage = Nothing
        ElseIf new_row - row = -2 And new_col - col = 2 Then
            board(row - 1, col + 1) = "O"
            buttons(row - 1, col + 1).BackgroundImage = Nothing
        ElseIf new_row - row = -2 And new_col - col = -2 Then
            board(row - 1, col - 1) = "O"
            buttons(row - 1, col - 1).BackgroundImage = Nothing
        End If

    End Function

'This is the troubling function************************

    Function build_tree(ByRef a_play As play)
        Dim nugga(,) As Char = board 'This is the First array
        Dim count As Integer = 0
        Dim wiii(,) As Char = board 'This is the second
        For i = 2 To 7
            For j = 0 To 7
                If a_play.board_play(i, j) = "b" OrElse a_play.board_play(i, j) = "B" Then
                    mark_black(wiii, i, j) 'calculate possible moves for each piece
                    For i2 = 3 To 7
                        For j2 = 0 To 7 'for every move calculated
                            If wiii(i2, j2) = "M" Then 'if sinlge jump
                                nugga = Nothing
                                nugga = board
                                
                                nugga(i, j) = "O"
                                nugga(i2, j2) = "b"

                                wiii(i, j) = "b"         'These values are also copied in nugga(i,j)
                                wiii(i2, j2) = "Y"      'and nugga(i2,j2)

                                a_print(wiii) 'print in list_box1
                                a_print2(nugga) 'print in list_box2

                                count = count + 1

                            ElseIf wiii(i2, j2) = "C" Then 'else if a capture
                                ReDim Preserve a_play.children(count)
                                a_play.children(count) = New play ' create new child
                                play_black(a_play.children(count).board_play, i, j, i2, j2)
                                a_play.children(count).eval = eval_funct(a_play.children(count).board_play)
                                'a_print(a_play.children(count).board_play)
                                count = count + 1
                            Else
                                ListBox1.Items.Add("BAH")
                            End If
                        Next
                    Next

                End If
            Next
        Next
    End Function
    Function black_move() As Nullable
        Dim root As play = New play
        Dim count As Integer = 0
        root.board_play = board
        'temp_board = board
        build_tree(root)
    End Function

    Function click_button(ByVal x As Integer, ByVal y As Integer) As Nullable
        If board(x, y) = "r" OrElse board(x, y) = "R" Then
            clear_V()
            no_highlight()
            temp_piece = board(x, y)
            selected = True
            highlight(x, y)
            temp_row = x
            temp_col = y
            temp_image = buttons(x, y).BackgroundImage
            selected = True
        ElseIf selected = True And buttons(x, y).BackColor = darkblue And board(x, y) = "V" Then
            no_highlight()
            buttons(x, y).BackgroundImage = temp_image
            board(x, y) = temp_piece
            buttons(x, y).BackgroundImageLayout = ImageLayout.Stretch
            buttons(temp_row, temp_col).BackgroundImage = Nothing
            buttons(temp_row, temp_col).BackColor = seagreen
            board(temp_row, temp_col) = "O"
            selected = False
            eat(x, y)
            clear_V()
            If x = 0 Then
                board(x, y) = "R"
                buttons(x, y).BackgroundImage = Image.FromFile(red_king_path)
            End If
            black_move()
        ElseIf selected = True And buttons(x, y).BackColor = darkblue Then
            no_highlight()
            buttons(x, y).BackgroundImage = temp_image
            board(x, y) = temp_piece
            buttons(x, y).BackgroundImageLayout = ImageLayout.Stretch
            buttons(temp_row, temp_col).BackgroundImage = Nothing
            buttons(temp_row, temp_col).BackColor = seagreen
            board(temp_row, temp_col) = "O"
            selected = False
            clear_V()
            If x = 0 Then
                board(x, y) = "R"
                buttons(x, y).BackgroundImage = Image.FromFile(red_king_path)
            End If
            black_move()
        End If
        'print()
    End Function
    Private Sub b01_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b01.Click
        click_button(0, 1)
    End Sub
    Private Sub b03_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b03.Click
        click_button(0, 3)
    End Sub
    Private Sub b05_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b05.Click
        click_button(0, 5)
    End Sub
    Private Sub b07_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b07.Click
        click_button(0, 7)
    End Sub
    Private Sub b10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b10.Click
        click_button(1, 0)
    End Sub
    Private Sub b12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b12.Click
        click_button(1, 2)
    End Sub
    Private Sub b14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b14.Click
        click_button(1, 4)
    End Sub
    Private Sub b16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b16.Click
        click_button(1, 6)
    End Sub
    Private Sub b21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b21.Click
        click_button(2, 1)
    End Sub
    Private Sub b23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b23.Click
        click_button(2, 3)
    End Sub
    Private Sub b25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b25.Click
        click_button(2, 5)
    End Sub
    Private Sub b27_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b27.Click
        click_button(2, 7)
    End Sub
    Private Sub b30_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b30.Click
        click_button(3, 0)
    End Sub
    Private Sub b32_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b32.Click
        click_button(3, 2)
    End Sub
    Private Sub b34_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b34.Click
        click_button(3, 4)
    End Sub
    Private Sub b36_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b36.Click
        click_button(3, 6)
    End Sub
    Private Sub b41_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b41.Click
        click_button(4, 1)
    End Sub
    Private Sub b43_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b43.Click
        click_button(4, 3)
    End Sub
    Private Sub b45_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b45.Click
        click_button(4, 5)
    End Sub
    Private Sub b47_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b47.Click
        click_button(4, 7)
    End Sub
    Private Sub b50_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b50.Click
        click_button(5, 0)
    End Sub
    Private Sub b52_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b52.Click
        click_button(5, 2)
    End Sub
    Private Sub b54_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b54.Click
        click_button(5, 4)
    End Sub
    Private Sub b56_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b56.Click
        click_button(5, 6)
    End Sub
    Private Sub b61_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b61.Click
        click_button(6, 1)
    End Sub
    Private Sub b63_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b63.Click
        click_button(6, 3)
    End Sub
    Private Sub b65_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b65.Click
        click_button(6, 5)
    End Sub
    Private Sub b67_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b67.Click
        click_button(6, 7)
    End Sub
    Private Sub b70_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b70.Click
        click_button(7, 0)
    End Sub
    Private Sub b72_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b72.Click
        click_button(7, 2)
    End Sub
    Private Sub b74_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b74.Click
        click_button(7, 4)
    End Sub
    Private Sub b76_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b76.Click
        click_button(7, 6)
    End Sub

End Class
 
We didnt need ALL the code :)

VB.NET:
Dim nugga(,) As Char = board 'This is the First array
        Dim count As Integer = 0
        Dim wiii(,) As Char = board 'This is the second

You havent copied "board" into "nugga" - you have set "nugga" to reference "board". You've done the same with "wiii".

So when you change a value in "nugga", you're actually changing the value in "board" which, in turn, shows up in "wiii".
 
We didnt need ALL the code :)

VB.NET:
Dim nugga(,) As Char = board 'This is the First array
        Dim count As Integer = 0
        Dim wiii(,) As Char = board 'This is the second

You havent copied "board" into "nugga" - you have set "nugga" to reference "board". You've done the same with "wiii".

So when you change a value in "nugga", you're actually changing the value in "board" which, in turn, shows up in "wiii".

Sweet! Thanks!:D
 
Back
Top