Snakes and Ladders Program. Problem with code.

Netto

Member
Joined
Jan 7, 2008
Messages
8
Programming Experience
Beginner
Hi guys,

I'm having a little problem with some code for a snakes and ladders problem.

The problem is with this line - EmptyBitmap(P).SetPixel(i, j, BoardBitmap.GetPixel(L + i, T + j)).

VB.net says that the problem is Parameter must be positive and < Height.
Parameter name: y

I can't figure out how to fix this, so any help would be appreciated.

I'm a complete novice when it comes to programming but here is my code for the specific problem -

VB.NET:
Public Sub MovePlayer(ByVal Draw As Boolean)
        Dim L As Integer
        Dim T As Integer
        Dim BN As Integer

        BN = CInt(bitmap(P).Tag) - 1

        L = (BN Mod 10) * 50
        T = Int(BN / 10) * 50

        If Int(BN / 10) / 2 <> Int(Int(BN / 10) / 2) Then
            L = PicBoard.Width - L - 50
        End If
        T = PicBoard.Height + T

        If P = 0 Then
            T = T + 20
        ElseIf P = 1 Then
            L = L - 30
            T = T + 20
        ElseIf P = 2 Then
            L = L - 30
            T = T + 50
        ElseIf P = 3 Then
            T = T + 50
        End If

        Dim i As Integer
        Dim j As Integer

        If Draw Then
            For i = 0 To EmptyBitmap(P).Width + 1
                For j = 0 To EmptyBitmap(P).Height - 1
                    EmptyBitmap(P).SetPixel(i, j, BoardBitmap.GetPixel(L + i, T + j))
                Next j
            Next
            Player(P) = PicBoard.CreateGraphics()
            Player(P).DrawImage(bitmap(P), L, T, bitmap(P).Width, bitmap(P).Height)
        Else
            Player(P) = PicBoard.CreateGraphics()
            Player(P).DrawImage(EmptyBitmap(P), L, T, EmptyBitmap(P).Width, EmptyBitmap(P).Height)
        End If
        Player(P).Dispose()
    End Sub


Thanks in advance.
 
Last edited by a moderator:
The problem is with this line - EmptyBitmap(P).SetPixel(i, j, BoardBitmap.GetPixel(L + i, T + j)).

you know that the .SetPixel - x+y are greater than 0 because they are your i+j loops, so the problem must be L or T. looking at the previous part of the code, it looks like L might be a negative value.

EDIT: although the error says parameter = y, so T + j is either less than 0 or greater than EmptyBitmap.width - 1
 
I fiddled around with it a bit and realised I still had it set up for four players, instead of just two.

If P = 0 Then
T = T - 20
ElseIf P = 1 Then
L = L - 30
T = T - 20
End If


I removed the two extra players but then the same error appeared..just in a different place - on the Else command.

Else
Player(P) = PicBoard.CreateGraphics()
Player(P).DrawImage(EmptyBitmap(P), L, T, EmptyBitmap(P).Width, EmptyBitmap(P).Height)
End If


I'm seriously confused as to what is causing the problem. I'd also just to like point out that the game runs from left to right and has 100 squares. The size of the board is 579, 505 and is a picture within a picture box.

EDIT: I'd also like to point out that I'm trying to sort this bit out so that the player's icons will appear on square number 1. As soon as I run the program and click "New Game" the program debugs with the above error.

Thanks again.
 
Last edited:
you need to check that your variable values are what you're expecting them to be

VB.NET:
Else
    Player(P) = PicBoard.CreateGraphics()
    debug.print L & " / " & T
    Player(P).DrawImage(EmptyBitmap(P), L, T, EmptyBitmap(P).Width, EmptyBitmap(P).Height)
End If
 
I still can't fix it. I've decided I'm virtually useless with programming. Here's my full code -

VB.NET:
Imports System
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

Public Class frmMain

    Dim P As Integer
    Dim PN As Integer
    Dim DN As Integer
    Dim DorU As Integer
    Dim WinNo As Integer

    Dim NowPlaying As Boolean

    Dim Player(2) As Graphics
    Dim img(4) As Image
    Dim bitmap(4) As Bitmap
    Dim EmptyImg As Image
    Dim EmptyBitmap(4) As Bitmap
    Dim BoardImg As Image
    Dim BoardBitmap As Bitmap

    Dim DiceImg(6) As Image

    Dim Winner(2) As System.Windows.Forms.Label

    Private Sub picNewGame_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picNewGame.MouseDown
        picNewGame.Image = My.Resources.NewGame2
    End Sub

    Private Sub picNewGame_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picNewGame.MouseUp
        picNewGame.Image = My.Resources.NewGame1

        DiceTimer.Enabled = False

        If Choice2.Checked = True Then
            PN = 2
        End If

        For P = 0 To 1
            bitmap(P).Tag = "1"
            Player(P) = PicBoard.CreateGraphics()
            Player(P).Clear(BackColor)
            Player(P).Dispose()
        Next P
        PicBoard.Refresh()

        For P = 0 To PN - 1
            MovePlayer(True)
        Next P

        P = -1
        IncP()

        DN = 1
        DorU = 0

        Rubber.Visible = False
        Winner(0).Visible = False
        Winner(1).Visible = False
        Turn.Visible = True
        NowPlaying = True
    End Sub

    Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If NowPlaying Then
            If MsgBox("Are you sure you want to exit the game?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then
                e.Cancel = True
            End If
        End If
    End Sub

    Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        NowPlaying = False

        DiceImg(0) = My.Resources.Dice1
        DiceImg(1) = My.Resources.Dice2
        DiceImg(2) = My.Resources.Dice3
        DiceImg(3) = My.Resources.Dice4
        DiceImg(4) = My.Resources.Dice5
        DiceImg(5) = My.Resources.Dice6

        img(0) = My.Resources.RedPlayer
        img(1) = My.Resources.BluePlayer

        For P = 0 To 1
            bitmap(P) = New Bitmap(img(P), img(P).Width, img(P).Height)
            bitmap(P).MakeTransparent(System.Drawing.Color.White)
        Next P

        Dim i As Integer
        Dim j As Integer
        Dim k As Integer

        EmptyImg = My.Resources.EmptyPlayer
        For i = 0 To 1
            EmptyBitmap(i) = New Bitmap(EmptyImg, EmptyImg.Width, EmptyImg.Height)
            For j = 0 To EmptyBitmap(i).Width - 1
                For k = 0 To EmptyBitmap(i).Height - 1
                    EmptyBitmap(i).SetPixel(j, k, Color.White)
                Next k
            Next j
        Next i

        BoardImg = My.Resources.snakes2
        BoardBitmap = New Bitmap(BoardImg, BoardImg.Width, BoardImg.Height)

        For i = 0 To 1
            Winner(i) = New System.Windows.Forms.Label
            Winner(i).Size() = New Size(52, 16)
            Winner(i).Font() = New System.Drawing.Font(Turn.Font.Name, 10, Turn.Font.Style, Turn.Font.Unit)
            Winner(i).AutoSize = True
            Winner(i).BackColor = Color.White
            Winner(i).ForeColor = Color.Black
            Winner(i).Text() = "Winner"
        Next i

        Me.Controls.AddRange(Winner)

        Winner(0).Location = New System.Drawing.Point(501, 308)
        Winner(1).Location = New System.Drawing.Point(501, 334)

        For i = 0 To 1
            Winner(i).BringToFront()
            Winner(i).Visible = True
        Next i
    End Sub

    Public Sub MovePlayer(ByVal Draw As Boolean)
        Dim L As Integer
        Dim T As Integer
        Dim BN As Integer

        BN = CInt(bitmap(P).Tag) - 1

        L = (BN Mod 10) * 50
        T = Int(BN / 10) * 50

        If Int(BN / 10) / 2 <> Int(Int(BN / 10) / 2) Then
            L = PicBoard.Width - L - 50
        End If
        T = PicBoard.Height - T

        If P = 0 Then
            T = T - 20
        ElseIf P = 1 Then
            L = L + 30
            T = T - 20
        End If

        Dim i As Integer
        Dim j As Integer

        If Draw Then
            For i = 0 To EmptyBitmap(P).Width - 1
                For j = 0 To EmptyBitmap(P).Height - 1
                    EmptyBitmap(P).SetPixel(i, j, BoardBitmap.GetPixel(L + i, T + j))
                Next j
            Next
            Player(P) = PicBoard.CreateGraphics()
            Player(P).DrawImage(bitmap(P), L, T, bitmap(P).Width, bitmap(P).Height)
        Else
            Player(P) = PicBoard.CreateGraphics()
            Player(P).DrawImage(EmptyBitmap(P), L, T, EmptyBitmap(P).Width, EmptyBitmap(P).Height)
        End If
        Player(P).Dispose()
    End Sub

    Public Sub IncP()
NextPlayer:
        P = P - 1
        If P > PN + 1 Then P = 0
        If bitmap(P).Tag = "100" Then GoTo NextPlayer

        DiceTimer.Interval = 100 - Int((CInt(bitmap(P).Tag) - 1) / 8) * 10

        If P = 0 Then
            Turn.Text = "RED Turn"
            Turn.ForeColor = Color.Red
        ElseIf P = 1 Then
            Turn.Text = "BLUE Turn"
            Turn.ForeColor = Color.Yellow
        End If
    End Sub

    Private Sub DiceTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DiceTimer.Tick
        DN = DN + 1
        If DN > 6 Then DN = 1

        picDice.Image = DiceImg(DN - 1)
        picDice.Tag = CStr(DN) 'DicePic(DN - 1).Tag
    End Sub

    Private Sub picDice_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picDice.Click
        If NowPlaying = False Then Exit Sub

        Dim i As Integer
        Dim G As Integer
        Dim N As Integer
        Dim D As Integer

        If DorU = 0 Then
            DorU = 1
            DiceTimer.Enabled = True
        Else
            DorU = 0
            DiceTimer.Enabled = False


            G = CInt(bitmap(P).Tag)

            N = CInt(picDice.Tag)

            D = G + N

            MovePlayer(False)
            If D <= 100 Then
                bitmap(P).Tag = CStr(D)
            End If
            MovePlayer(True)

            If D = 9 Then
                MovePlayer(False)
                bitmap(P).Tag = "2"
                MovePlayer(True)
            ElseIf D = 12 Then
                MovePlayer(False)
                bitmap(P).Tag = "19"
                MovePlayer(True)
            ElseIf D = 18 Then
                MovePlayer(False)
                bitmap(P).Tag = "11"
                MovePlayer(True)
            ElseIf D = 24 Then
                MovePlayer(False)
                bitmap(P).Tag = "31"
                MovePlayer(True)
            ElseIf D = 27 Then
                MovePlayer(False)
                bitmap(P).Tag = "20"
                MovePlayer(True)
            ElseIf D = 36 Then
                MovePlayer(False)
                bitmap(P).Tag = "29"
                MovePlayer(True)
            ElseIf D = 45 Then
                MovePlayer(False)
                bitmap(P).Tag = "38"
                MovePlayer(True)
            ElseIf D = 48 Then
                MovePlayer(False)
                bitmap(P).Tag = "55"
                MovePlayer(True)
            ElseIf D = 54 Then
                MovePlayer(False)
                bitmap(P).Tag = "47"
                MovePlayer(True)
            ElseIf D = 60 Then
                MovePlayer(False)
                bitmap(P).Tag = "67"
                MovePlayer(True)
            ElseIf D = 63 Then
                MovePlayer(False)
                bitmap(P).Tag = "56"
                MovePlayer(True)
            ElseIf D = 72 Then
                MovePlayer(False)
                bitmap(P).Tag = "65"
                MovePlayer(True)
            ElseIf D = 81 Then
                MovePlayer(False)
                bitmap(P).Tag = "74"
                MovePlayer(True)
            ElseIf D = 84 Then
                MovePlayer(False)
                bitmap(P).Tag = "91"
                MovePlayer(True)
            ElseIf D = 90 Then
                MovePlayer(False)
                bitmap(P).Tag = "83"
                MovePlayer(True)
            ElseIf D = 99 Then
                MovePlayer(False)
                bitmap(P).Tag = "93"
                MovePlayer(True)
            End If

            If bitmap(P).Tag = "100" Then
                If P = 0 Then
                    Winner(WinNo).Text = "Red"
                    Winner(WinNo).ForeColor = Color.Red
                ElseIf P = 1 Then
                    Winner(WinNo).Text = "Blue"
                    Winner(WinNo).ForeColor = Color.Blue
                End If
                Winner(WinNo).Visible = True
                WinNo = WinNo + 1
            End If

            If WinNo = PN - 1 Then
                For i = 0 To PN - 1
                    If bitmap(i).Tag <> "100" Then
                        If i = 0 Then
                            Winner(WinNo).Text = "Red"
                            Winner(WinNo).ForeColor = Color.Red
                        ElseIf i = 1 Then
                            Winner(WinNo).Text = "Blue"
                            Winner(WinNo).ForeColor = Color.Blue
                        End If
                        Winner(WinNo).Visible = True

                        DiceTimer.Enabled = False
                        Turn.Visible = False
                        Rubber.Visible = True
                        NowPlaying = False
                        Exit Sub
                    End If
                Next i
            End If

            IncP()

        End If
    End Sub

Any ideas why it doesn't work? The help is always appreciated and urgently wanted.

Thanks again.
 
Last edited by a moderator:
if you want to upload the project (zipped) i'll debug it for you.
i can't do it (easily) without all the images
 
Thanks very much. I've managed to fix that bit of it somehow (just by fiddling around really).

http://www.uploading.com/files/XBKPSB81/Snake_and_Ladder_Board_Game.rar.html

The problem I have now is this line - If bitmap(P).Tag = "100" Then

The debugger says that it's outside the bounds of the array. Now I have knowledge of arrays but I can't for the life of me figure out where to change it so this bit works.

Thanks again and sorry for the hassle.
 
its the arrayindex.
as i said earlier, you should use either debug.print or just a msgbox in your code to check your variables, (in this case P) are what you expect them to be. then you can trace it back to where P is set
 
You're going to hate me for this but I can't get the debug.print thing to work so could you (if you have the time) debug my code for me if possible?

I've included my entire project in the above link.

Thanks again
 
i've had a bit of a look at it.
i managed to get it running by editing the picDice_Click event
+ inserting

VB.NET:
If P = 0 Then
   P = 1
Else
   P = 0
End If

at the end of the sub before the

VB.NET:
IncP()

call.

then in IncP() i've commented out 'P = P - 1

VB.NET:
Public Sub IncP()
NextPlayer:
        'P = P - 1
        If P > PN + 1 Then P = 0
        If bitmap(P).Tag = "100" Then GoTo NextPlayer

        DiceTimer.Interval = 100 - Int((CInt(bitmap(P).Tag) - 1) / 8) * 10

        If P = 0 Then
            Turn.Text = "RED Turn"
            Turn.ForeColor = Color.Red
        ElseIf P = 1 Then
            Turn.Text = "BLUE Turn"
            Turn.ForeColor = Color.Yellow
        End If
    End Sub
 
Ok I did exactly what you listed here to the letter but it still doesn't work. The game will run as usual but as soon as I choose New Game it'll go back into debug mode complaining about the array problem again.

Thanks
 
heres all the changes i've made

VB.NET:
Imports System
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

Public Class frmMain

    Dim P As Integer
    Dim PN As Integer
    Dim DN As Integer
    Dim DorU As Integer
    Dim WinNo As Integer

    Dim NowPlaying As Boolean

    Dim Player(2) As Graphics
    Dim img(4) As Image
    Dim bitmap(4) As Bitmap
    Dim EmptyImg As Image
    Dim EmptyBitmap(4) As Bitmap
    Dim BoardImg As Image
    Dim BoardBitmap As Bitmap

    Dim DiceImg(6) As Image

    Dim Winner(2) As System.Windows.Forms.Label

    Private Sub picNewGame_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picNewGame.MouseDown
        picNewGame.Image = My.Resources.NewGame2
    End Sub

    Private Sub picNewGame_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picNewGame.MouseUp
        picNewGame.Image = My.Resources.NewGame1

        DiceTimer.Enabled = False

        If Choice2.Checked = True Then
            PN = 2
        End If

        For P = 0 To 1
            bitmap(P).Tag = "1"
            Player(P) = PicBoard.CreateGraphics()
            Player(P).Clear(BackColor)
            Player(P).Dispose()
        Next P
        PicBoard.Refresh()

        For P = 0 To PN - 1
            MovePlayer(True)
        Next P

        P = 0 '-1
        IncP()

        DN = 1
        DorU = 0

        Rubber.Visible = False
        Winner(0).Visible = False
        Winner(1).Visible = False
        Turn.Visible = True
        NowPlaying = True
    End Sub

    Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If NowPlaying Then
            If MsgBox("Are you sure you want to exit the game?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then
                e.Cancel = True
            End If
        End If
    End Sub

    Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        NowPlaying = False

        DiceImg(0) = My.Resources.Dice1
        DiceImg(1) = My.Resources.Dice2
        DiceImg(2) = My.Resources.Dice3
        DiceImg(3) = My.Resources.Dice4
        DiceImg(4) = My.Resources.Dice5
        DiceImg(5) = My.Resources.Dice6

        img(0) = My.Resources.RedPlayer
        img(1) = My.Resources.BluePlayer

        For P = 0 To 1
            bitmap(P) = New Bitmap(img(P), img(P).Width, img(P).Height)
            bitmap(P).MakeTransparent(System.Drawing.Color.White)
        Next P

        Dim i As Integer
        Dim j As Integer
        Dim k As Integer

        EmptyImg = My.Resources.EmptyPlayer
        For i = 0 To 1
            EmptyBitmap(i) = New Bitmap(EmptyImg, EmptyImg.Width, EmptyImg.Height)
            For j = 0 To EmptyBitmap(i).Width - 1
                For k = 0 To EmptyBitmap(i).Height - 1
                    EmptyBitmap(i).SetPixel(j, k, Color.White)
                Next k
            Next j
        Next i

        BoardImg = My.Resources.Board
        BoardBitmap = New Bitmap(BoardImg, BoardImg.Width, BoardImg.Height)

        For i = 0 To 1
            Winner(i) = New System.Windows.Forms.Label
            Winner(i).Size() = New Size(52, 16)
            Winner(i).Font() = New System.Drawing.Font(Turn.Font.Name, 10, Turn.Font.Style, Turn.Font.Unit)
            Winner(i).AutoSize = True
            Winner(i).BackColor = Color.White
            Winner(i).ForeColor = Color.Black
            Winner(i).Text() = "Winner"
        Next i

        For i = 0 To 1
            Winner(i).BringToFront()
            Winner(i).Visible = True
        Next i
    End Sub

    Public Sub MovePlayer(ByVal Draw As Boolean)
        Dim L As Integer
        Dim T As Integer
        Dim BN As Integer

        BN = CInt(bitmap(P).Tag) - 1

        L = (BN Mod 10) * 50
        T = Int(BN / 10) * 50

        If Int(BN / 10) / 2 <> Int(Int(BN / 10) / 2) Then
            L = PicBoard.Width - L - 50
        End If
        T = PicBoard.Height - T

        If P = 0 Then
            T = T - 20
        ElseIf P = 1 Then
            L = L + 30
            T = T - 20
        End If

        Dim i As Integer
        Dim j As Integer

        If Draw Then
            For i = 0 To EmptyBitmap(P).Width - 1
                For j = 0 To EmptyBitmap(P).Height - 1
                    EmptyBitmap(P).SetPixel(i, j, BoardBitmap.GetPixel(L + i, T + j))
                Next j
            Next

            Player(P) = PicBoard.CreateGraphics()
            Player(P).DrawImage(bitmap(P), L, T, bitmap(P).Width, bitmap(P).Height)
        Else
            Player(P) = PicBoard.CreateGraphics()
            Player(P).DrawImage(EmptyBitmap(P), L, T, EmptyBitmap(P).Width, EmptyBitmap(P).Height)
        End If
        Player(P).Dispose()
    End Sub

    Public Sub IncP()
NextPlayer:
        'P = P - 1
        If P > PN + 1 Then P = 0
        If bitmap(P).Tag = "100" Then GoTo NextPlayer

        DiceTimer.Interval = 100 - Int((CInt(bitmap(P).Tag) - 1) / 8) * 10

        If P = 0 Then
            Turn.Text = "RED Turn"
            Turn.ForeColor = Color.Red
        ElseIf P = 1 Then
            Turn.Text = "BLUE Turn"
            Turn.ForeColor = Color.Yellow
        End If
    End Sub

    Private Sub DiceTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DiceTimer.Tick
        DN = DN + 1
        If DN > 6 Then DN = 1

        picDice.Image = DiceImg(DN - 1)
        picDice.Tag = CStr(DN) 'DicePic(DN - 1).Tag
    End Sub

    Private Sub picDice_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picDice.Click
        If NowPlaying = False Then Exit Sub

        Dim i As Integer
        Dim G As Integer
        Dim N As Integer
        Dim D As Integer

        If DorU = 0 Then
            DorU = 1
            DiceTimer.Enabled = True
        Else
            DorU = 0
            DiceTimer.Enabled = False


            G = CInt(bitmap(P).Tag)

            N = CInt(picDice.Tag)

            D = G + N

            MovePlayer(False)
            If D <= 100 Then
                bitmap(P).Tag = CStr(D)
            End If
            MovePlayer(True)

            'If D = 9 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "2"
            '    MovePlayer(True)
            'ElseIf D = 12 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "19"
            '    MovePlayer(True)
            'ElseIf D = 18 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "11"
            '    MovePlayer(True)
            'ElseIf D = 24 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "31"
            '    MovePlayer(True)
            'ElseIf D = 27 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "20"
            '    MovePlayer(True)
            'ElseIf D = 36 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "29"
            '    MovePlayer(True)
            'ElseIf D = 45 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "38"
            '    MovePlayer(True)
            'ElseIf D = 48 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "55"
            '    MovePlayer(True)
            'ElseIf D = 54 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "47"
            '    MovePlayer(True)
            'ElseIf D = 60 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "67"
            '    MovePlayer(True)
            'ElseIf D = 63 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "56"
            '    MovePlayer(True)
            'ElseIf D = 72 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "65"
            '    MovePlayer(True)
            'ElseIf D = 81 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "74"
            '    MovePlayer(True)
            'ElseIf D = 84 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "91"
            '    MovePlayer(True)
            'ElseIf D = 90 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "83"
            '    MovePlayer(True)
            'ElseIf D = 99 Then
            '    MovePlayer(False)
            '    'bitmap(P).Tag = "93"
            '    MovePlayer(True)
            'End If

            If bitmap(P).Tag = "100" Then
                If P = 0 Then
                    Winner(WinNo).Text = "Red"
                    Winner(WinNo).ForeColor = Color.Red
                ElseIf P = 1 Then
                    Winner(WinNo).Text = "Blue"
                    Winner(WinNo).ForeColor = Color.Blue
                End If
                Winner(WinNo).Visible = True
                WinNo = WinNo + 1
            End If

            If WinNo = PN - 1 Then
                For i = 0 To PN - 1
                    If bitmap(i).Tag <> "100" Then
                        If i = 0 Then
                            Winner(WinNo).Text = "Red"
                            Winner(WinNo).ForeColor = Color.Red
                        ElseIf i = 1 Then
                            Winner(WinNo).Text = "Blue"
                            Winner(WinNo).ForeColor = Color.Blue
                        End If
                        Winner(WinNo).Visible = True

                        DiceTimer.Enabled = False
                        Turn.Visible = False
                        Rubber.Visible = True
                        NowPlaying = False
                        Exit Sub
                    End If
                Next i
            End If

            If P = 0 Then
                P = 1
            Else
                P = 0
            End If

            IncP()

            End If
    End Sub
End Class
 
Excellent! Thank you, it now works....except for one thing.

That long bit you took out in the Dice_Click area was meant to move the counters up and down respective snakes and ladders. Each ladder was on a multiple of 12 and every snakes on a multiple of 9. Where a snake and a ladder fell on the same square, the snake would win over the ladder. Each snake or ladder was meant to move the player's counters back or forwards 7 spaces.

Is there anyway of doing this with my current code or would I have to change things?

Thanks very very much.
 
Back
Top