locked
Grid Help RRS feed

  • Question

  • Having a issue with my grid. Its not building my grid or even hiting everything. here is my code.

    Public Class frmGame
        Dim Grid(10, 10) As PictureBox
        Dim RanJewel As Random
        Dim Jewel As Integer
        Dim JewelImg As Bitmap
    
        Private Sub frmGame_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            BuildGrid()
        End Sub
    
        Public Sub DrawGrid(ByVal row As Integer, ByVal column As Integer)
            Grid(0, 0).Location = New Point(413, 90)
            Grid(row, column) = New PictureBox
            Grid(row, column).Name = "pbGrid_" & row.ToString & "_" & column.ToString
            Grid(row, column).Size = New Point(50, 50)
            Grid(row, column).BorderStyle = BorderStyle.None
            Grid(row, column).BackColor = Color.Transparent
            Grid(row, column).BackgroundImage = JewelImg
            Grid(row, column).Location = New Point((Grid(row, column).Width * column), (Grid(row, column).Height * row))
        End Sub
    
        Public Sub BuildGrid()
            For row = 0 To 10
                For column = 0 To 10
                    GridValue()
                    DrawGrid(row, column)
                Next
            Next
        End Sub
    
        Public Sub GridClick(ByVal sender As PictureBox, ByVal e As EventArgs)
            MyBase.OnClick(e)
            MsgBox(sender.Name.ToString & " has been clicked", MsgBoxStyle.Information, "Click Event")
        End Sub
    
        Public Sub GridValue()
            RanJewel = New Random
            Jewel = RanJewel.Next(0, 42)
            Select Case Jewel
                Case 0
                    JewelImg = New Bitmap("Jewels\Blue_1.png")
                Case 1
                    JewelImg = New Bitmap("Jewels\Blue_2.png")
                Case 2
                    JewelImg = New Bitmap("Jewels\Blue_3.png")
                Case 3
                    JewelImg = New Bitmap("Jewels\Blue_4.png")
                Case 4
                    JewelImg = New Bitmap("Jewels\Blue_5.png")
                Case 5
                    JewelImg = New Bitmap("Jewels\Blue_6.png")
                Case 6
                    JewelImg = New Bitmap("Jewels\Blue_7.png")
                Case 7
                    JewelImg = New Bitmap("Jewels\Green_1.png")
                Case 8
                    JewelImg = New Bitmap("Jewels\Green_2.png")
                Case 9
                    JewelImg = New Bitmap("Jewels\Green_3.png")
                Case 10
                    JewelImg = New Bitmap("Jewels\Green_4.png")
                Case 11
                    JewelImg = New Bitmap("Jewels\Green_5.png")
                Case 12
                    JewelImg = New Bitmap("Jewels\Green_6.png")
                Case 13
                    JewelImg = New Bitmap("Jewels\Green_7.png")
                Case 14
                    JewelImg = New Bitmap("Jewels\Grey_1.png")
                Case 15
                    JewelImg = New Bitmap("Jewels\Grey_2.png")
                Case 16
                    JewelImg = New Bitmap("Jewels\Grey_3.png")
                Case 17
                    JewelImg = New Bitmap("Jewels\Grey_4.png")
                Case 18
                    JewelImg = New Bitmap("Jewels\Grey_5.png")
                Case 19
                    JewelImg = New Bitmap("Jewels\Grey_6.png")
                Case 20
                    JewelImg = New Bitmap("Jewels\Grey_7.png")
                Case 21
                    JewelImg = New Bitmap("Jewels\Purple_1.png")
                Case 22
                    JewelImg = New Bitmap("Jewels\Purple_2.png")
                Case 23
                    JewelImg = New Bitmap("Jewels\Purple_3.png")
                Case 24
                    JewelImg = New Bitmap("Jewels\Purple_4.png")
                Case 25
                    JewelImg = New Bitmap("Jewels\Purple_5.png")
                Case 26
                    JewelImg = New Bitmap("Jewels\Purple_6.png")
                Case 27
                    JewelImg = New Bitmap("Jewels\Purple_7.png")
                Case 28
                    JewelImg = New Bitmap("Jewels\Red_1.png")
                Case 29
                    JewelImg = New Bitmap("Jewels\Red_2.png")
                Case 30
                    JewelImg = New Bitmap("Jewels\Red_3.png")
                Case 31
                    JewelImg = New Bitmap("Jewels\Red_4.png")
                Case 32
                    JewelImg = New Bitmap("Jewels\Red_5.png")
                Case 33
                    JewelImg = New Bitmap("Jewels\Red_6.png")
                Case 34
                    JewelImg = New Bitmap("Jewels\Red_7.png")
                Case 35
                    JewelImg = New Bitmap("Jewels\Yellow_1.png")
                Case 36
                    JewelImg = New Bitmap("Jewels\Yellow_2.png")
                Case 37
                    JewelImg = New Bitmap("Jewels\Yellow_3.png")
                Case 38
                    JewelImg = New Bitmap("Jewels\Yellow_4.png")
                Case 39
                    JewelImg = New Bitmap("Jewels\Yellow_5.png")
                Case 40
                    JewelImg = New Bitmap("Jewels\Yellow_6.png")
                Case 41
                    JewelImg = New Bitmap("Jewels\Yellow_7.png")
                Case 42
                    JewelImg = New Bitmap("Jewels\Yellow_7.png")
            End Select
        End Sub
    End Class
    

    Saturday, April 6, 2013 4:11 PM

Answers

  • Solved issue but have new issue in seperate post

    Public Class frmGame
        Dim Grid(10, 10) As pbGrid
        Dim RanJewel As Random
        Dim Jewel As Integer
        Dim JewelImg As String
        Dim TurnOffSleep As Boolean
    
        Dim JewelValue As Integer
        Dim MasterJewelValue As Integer
        Dim MasterJewelTicker As Integer = 8
    
        Dim PlyScore As Integer
    
        Private Sub frmGame_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim RunOnce As Boolean
    
            MasterJewelTimer.Start()
    
            GridValue()
            BuildGrid()
    
            If RunOnce = False Then
                RunOnce = True
                pbMasterJewel.BackgroundImage = Image.FromFile(JewelImg)
            End If
        End Sub
    
        Public Sub DrawGrid(ByVal row As Integer, ByVal column As Integer)
            GridValue()
            Grid(row, column) = New pbGrid
            Grid(row, column).Name = "pbGrid_" & row.ToString & "_" & column.ToString
            Grid(row, column).Size = New Point(50, 50)
            Grid(row, column).BorderStyle = BorderStyle.None
            Grid(row, column).BackColor = Color.Transparent
            Grid(row, column).BackgroundImage = Image.FromFile(JewelImg)
            Grid(row, column).BackgroundImageLayout = ImageLayout.Stretch
            Grid(row, column).Location = New Point((Grid(row, column).Width * column) + 413, (Grid(row, column).Height * row) + 85)
            Me.Controls.Add(Grid(row, column))
        End Sub
    
        Public Sub BuildGrid()
            For row = 0 To 10
                For column = 0 To 10
                    DrawGrid(row, column)
                Next
            Next
    
            'Stop Sleep
            TurnOffSleep = True
        End Sub
    
        Public Sub GridValue()
            RanJewel = New Random
            Jewel = RanJewel.Next(0, 42)
            Select Case Jewel
                Case 0
                    JewelImg = "Jewels\Blue\Blue_1.png"
                Case 1
                    JewelImg = "Jewels\Blue\Blue_2.png"
                Case 2
                    JewelImg = "Jewels\Blue\Blue_3.png"
                Case 3
                    JewelImg = "Jewels\Blue\Blue_4.png"
                Case 4
                    JewelImg = "Jewels\Blue\Blue_5.png"
                Case 5
                    JewelImg = "Jewels\Blue\Blue_6.png"
                Case 6
                    JewelImg = "Jewels\Blue\Blue_7.png"
                Case 7
                    JewelImg = "Jewels\Green\Green_1.png"
                Case 8
                    JewelImg = "Jewels\Green\Green_2.png"
                Case 9
                    JewelImg = "Jewels\Green\Green_3.png"
                Case 10
                    JewelImg = "Jewels\Green\Green_4.png"
                Case 11
                    JewelImg = "Jewels\Green\Green_5.png"
                Case 12
                    JewelImg = "Jewels\Green\Green_6.png"
                Case 13
                    JewelImg = "Jewels\Green\Green_7.png"
                Case 14
                    JewelImg = "Jewels\Grey\Grey_1.png"
                Case 15
                    JewelImg = "Jewels\Grey\Grey_2.png"
                Case 16
                    JewelImg = "Jewels\Grey\Grey_3.png"
                Case 17
                    JewelImg = "Jewels\Grey\Grey_4.png"
                Case 18
                    JewelImg = "Jewels\Grey\Grey_5.png"
                Case 19
                    JewelImg = "Jewels\Grey\Grey_6.png"
                Case 20
                    JewelImg = "Jewels\Grey\Grey_7.png"
                Case 21
                    JewelImg = "Jewels\Purple\Purple_1.png"
                Case 22
                    JewelImg = "Jewels\Purple\Purple_2.png"
                Case 23
                    JewelImg = "Jewels\Purple\Purple_3.png"
                Case 24
                    JewelImg = "Jewels\Purple\Purple_4.png"
                Case 25
                    JewelImg = "Jewels\Purple\Purple_5.png"
                Case 26
                    JewelImg = "Jewels\Purple\Purple_6.png"
                Case 27
                    JewelImg = "Jewels\Purple\Purple_7.png"
                Case 28
                    JewelImg = "Jewels\Red\Red_1.png"
                Case 29
                    JewelImg = "Jewels\Red\Red_2.png"
                Case 30
                    JewelImg = "Jewels\Red\Red_3.png"
                Case 31
                    JewelImg = "Jewels\Red\Red_4.png"
                Case 32
                    JewelImg = "Jewels\Red\Red_5.png"
                Case 33
                    JewelImg = "Jewels\Red\Red_6.png"
                Case 34
                    JewelImg = "Jewels\Red\Red_7.png"
                Case 35
                    JewelImg = "Jewels\Yellow\Yellow_1.png"
                Case 36
                    JewelImg = "Jewels\Yellow\Yellow_2.png"
                Case 37
                    JewelImg = "Jewels\Yellow\Yellow_3.png"
                Case 38
                    JewelImg = "Jewels\Yellow\Yellow_4.png"
                Case 39
                    JewelImg = "Jewels\Yellow\Yellow_5.png"
                Case 40
                    JewelImg = "Jewels\Yellow\Yellow_6.png"
                Case 41
                    JewelImg = "Jewels\Yellow\Yellow_7.png"
                Case 42
                    JewelImg = "Jewels\Yellow\Yellow_7.png"
            End Select
    
            'Helps Randomize
            If TurnOffSleep = False Then
                System.Threading.Thread.Sleep(12)
            End If
        End Sub
    
        Public Sub GridClick(ByVal sender As pbGrid, ByVal e As EventArgs)
            Select Case sender.Name
                Case "pbGrid_0_0"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_1"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_2"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_3"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_4"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_5"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_6"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_7"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_8"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_9"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_10"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
            End Select
        End Sub
    
        Private Sub MasterJewelTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MasterJewelTimer.Tick
            If MasterJewelTicker <= 0 Then
                MasterJewelTicker = 8
                GridValue()
                pbMasterJewel.BackgroundImage = Image.FromFile(JewelImg)
            Else
                MasterJewelTicker -= 1
            End If
        End Sub
    
        Private Sub LblScore_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblScore.TextChanged
            Dim x As Integer = 93
            Dim y As Integer = 371
            If PlyScore > 999999999 Then
                PlyScore = 999999999
            Else
                For Each lblScore.Text.ToCharArray() As Char() (+1 Overloads)
                    lblScore.Location = New Point((x - lblScore.Text.Length), y)
                Next
            End If
        End Sub
    End Class
    
    Public Class pbGrid
        Inherits PictureBox
    
        Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
            frmGame.GridClick(Me, e)
            MyBase.OnClick(e)
        End Sub
    End Class
    

    • Marked as answer by mholmes_3038 Saturday, April 6, 2013 6:12 PM
    Saturday, April 6, 2013 6:12 PM

All replies

  • Im need to do the following:

    The starting point needs to be 413, 90

    Each picuture box needs to hold a Jewel Value and the Jewel Value will set its image as well

    I need a click event built so I know its working

    Currently:

    Currently its not even drawing the grid on screen so what did I do wrong and how do i accomplish the above?


    Saturday, April 6, 2013 4:16 PM
  • Ok I got most of this working using this code:

    Public Class frmGame
        Dim Grid(10, 10) As pbGrid
        Dim RanJewel As Random
        Dim Jewel As Integer
        Dim JewelImg As Bitmap
    
        Private Sub frmGame_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            BuildGrid()
        End Sub
    
        Public Sub DrawGrid(ByVal row As Integer, ByVal column As Integer)
            Grid(row, column) = New pbGrid
            Grid(row, column).Name = "pbGrid_" & row.ToString & "_" & column.ToString
            Grid(row, column).Size = New Point(50, 50)
            Grid(row, column).BorderStyle = BorderStyle.None
            Grid(row, column).BackColor = Color.Red
            Grid(row, column).BackgroundImage = JewelImg
            Grid(row, column).Location = New Point((Grid(row, column).Width * column) + 413, (Grid(row, column).Height * row) + 85)
            Me.Controls.Add(Grid(row, column))
        End Sub
    
        Public Sub BuildGrid()
            For row = 0 To 10
                For column = 0 To 10
                    DrawGrid(row, column)
                    'GridValue()
                Next
            Next
        End Sub
    
        Public Sub GridClick(ByVal sender As PictureBox, ByVal e As EventArgs)
            MyBase.OnClick(e)
            MsgBox(sender.Name.ToString & " has been clicked", MsgBoxStyle.Information, "Click Event")
        End Sub
    
        Public Sub GridValue()
            RanJewel = New Random
            Jewel = RanJewel.Next(0, 42)
            Select Case Jewel
                Case 0
                    JewelImg = New Bitmap("Jewels\Blue_1.png")
                Case 1
                    JewelImg = New Bitmap("Jewels\Blue_2.png")
                Case 2
                    JewelImg = New Bitmap("Jewels\Blue_3.png")
                Case 3
                    JewelImg = New Bitmap("Jewels\Blue_4.png")
                Case 4
                    JewelImg = New Bitmap("Jewels\Blue_5.png")
                Case 5
                    JewelImg = New Bitmap("Jewels\Blue_6.png")
                Case 6
                    JewelImg = New Bitmap("Jewels\Blue_7.png")
                Case 7
                    JewelImg = New Bitmap("Jewels\Green_1.png")
                Case 8
                    JewelImg = New Bitmap("Jewels\Green_2.png")
                Case 9
                    JewelImg = New Bitmap("Jewels\Green_3.png")
                Case 10
                    JewelImg = New Bitmap("Jewels\Green_4.png")
                Case 11
                    JewelImg = New Bitmap("Jewels\Green_5.png")
                Case 12
                    JewelImg = New Bitmap("Jewels\Green_6.png")
                Case 13
                    JewelImg = New Bitmap("Jewels\Green_7.png")
                Case 14
                    JewelImg = New Bitmap("Jewels\Grey_1.png")
                Case 15
                    JewelImg = New Bitmap("Jewels\Grey_2.png")
                Case 16
                    JewelImg = New Bitmap("Jewels\Grey_3.png")
                Case 17
                    JewelImg = New Bitmap("Jewels\Grey_4.png")
                Case 18
                    JewelImg = New Bitmap("Jewels\Grey_5.png")
                Case 19
                    JewelImg = New Bitmap("Jewels\Grey_6.png")
                Case 20
                    JewelImg = New Bitmap("Jewels\Grey_7.png")
                Case 21
                    JewelImg = New Bitmap("Jewels\Purple_1.png")
                Case 22
                    JewelImg = New Bitmap("Jewels\Purple_2.png")
                Case 23
                    JewelImg = New Bitmap("Jewels\Purple_3.png")
                Case 24
                    JewelImg = New Bitmap("Jewels\Purple_4.png")
                Case 25
                    JewelImg = New Bitmap("Jewels\Purple_5.png")
                Case 26
                    JewelImg = New Bitmap("Jewels\Purple_6.png")
                Case 27
                    JewelImg = New Bitmap("Jewels\Purple_7.png")
                Case 28
                    JewelImg = New Bitmap("Jewels\Red_1.png")
                Case 29
                    JewelImg = New Bitmap("Jewels\Red_2.png")
                Case 30
                    JewelImg = New Bitmap("Jewels\Red_3.png")
                Case 31
                    JewelImg = New Bitmap("Jewels\Red_4.png")
                Case 32
                    JewelImg = New Bitmap("Jewels\Red_5.png")
                Case 33
                    JewelImg = New Bitmap("Jewels\Red_6.png")
                Case 34
                    JewelImg = New Bitmap("Jewels\Red_7.png")
                Case 35
                    JewelImg = New Bitmap("Jewels\Yellow_1.png")
                Case 36
                    JewelImg = New Bitmap("Jewels\Yellow_2.png")
                Case 37
                    JewelImg = New Bitmap("Jewels\Yellow_3.png")
                Case 38
                    JewelImg = New Bitmap("Jewels\Yellow_4.png")
                Case 39
                    JewelImg = New Bitmap("Jewels\Yellow_5.png")
                Case 40
                    JewelImg = New Bitmap("Jewels\Yellow_6.png")
                Case 41
                    JewelImg = New Bitmap("Jewels\Yellow_7.png")
                Case 42
                    JewelImg = New Bitmap("Jewels\Yellow_7.png")
            End Select
        End Sub
    End Class
    
    Public Class pbGrid
        Inherits PictureBox
    
    End Class
    

    Now I just mostly need help getting it to randomly seelect a background image.
    Saturday, April 6, 2013 4:46 PM
  • GridValue() is awful.

    Renee


    "MODERN PROGRAMMING is deficient in elementary ways BECAUSE of problems INTRODUCED by MODERN PROGRAMMING." Me

    Saturday, April 6, 2013 4:48 PM
  • Tried this but still not working?????

    Public Class frmGame
        Dim Grid(10, 10) As pbGrid
        Dim RanJewel As Random
        Dim Jewel As Integer
        Dim JewelImg As String
    
        Private Sub frmGame_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            GridValue()
            BuildGrid()
        End Sub
    
        Public Sub DrawGrid(ByVal row As Integer, ByVal column As Integer)
            Grid(row, column) = New pbGrid
            Grid(row, column).Name = "pbGrid_" & row.ToString & "_" & column.ToString
            Grid(row, column).Size = New Point(50, 50)
            Grid(row, column).BorderStyle = BorderStyle.None
            Grid(row, column).BackColor = Color.Red
            Grid(row, column).BackgroundImage = Image.FromFile(JewelImg)
            Grid(row, column).Location = New Point((Grid(row, column).Width * column) + 413, (Grid(row, column).Height * row) + 85)
            Me.Controls.Add(Grid(row, column))
        End Sub
    
        Public Sub BuildGrid()
            For row = 0 To 10
                For column = 0 To 10
                    DrawGrid(row, column)
                Next
            Next
        End Sub
    
        Public Sub GridClick(ByVal sender As PictureBox, ByVal e As EventArgs)
            MyBase.OnClick(e)
            MsgBox(sender.Name.ToString & " has been clicked", MsgBoxStyle.Information, "Click Event")
        End Sub
    
        Public Sub GridValue()
            RanJewel = New Random
            Jewel = RanJewel.Next(0, 0)
            Select Case Jewel
                Case 0
                    JewelImg = "Jewels\Blue_1.png"
                    'Case 1
                    '    JewelImg = New Bitmap("Jewels\Blue_2.png")
                    'Case 2
                    '    JewelImg = New Bitmap("Jewels\Blue_3.png")
                    'Case 3
                    '    JewelImg = New Bitmap("Jewels\Blue_4.png")
                    'Case 4
                    '    JewelImg = New Bitmap("Jewels\Blue_5.png")
                    'Case 5
                    '    JewelImg = New Bitmap("Jewels\Blue_6.png")
                    'Case 6
                    '    JewelImg = New Bitmap("Jewels\Blue_7.png")
                    'Case 7
                    '    JewelImg = New Bitmap("Jewels\Green_1.png")
                    'Case 8
                    '    JewelImg = New Bitmap("Jewels\Green_2.png")
                    'Case 9
                    '    JewelImg = New Bitmap("Jewels\Green_3.png")
                    'Case 10
                    '    JewelImg = New Bitmap("Jewels\Green_4.png")
                    'Case 11
                    '    JewelImg = New Bitmap("Jewels\Green_5.png")
                    'Case 12
                    '    JewelImg = New Bitmap("Jewels\Green_6.png")
                    'Case 13
                    '    JewelImg = New Bitmap("Jewels\Green_7.png")
                    'Case 14
                    '    JewelImg = New Bitmap("Jewels\Grey_1.png")
                    'Case 15
                    '    JewelImg = New Bitmap("Jewels\Grey_2.png")
                    'Case 16
                    '    JewelImg = New Bitmap("Jewels\Grey_3.png")
                    'Case 17
                    '    JewelImg = New Bitmap("Jewels\Grey_4.png")
                    'Case 18
                    '    JewelImg = New Bitmap("Jewels\Grey_5.png")
                    'Case 19
                    '    JewelImg = New Bitmap("Jewels\Grey_6.png")
                    'Case 20
                    '    JewelImg = New Bitmap("Jewels\Grey_7.png")
                    'Case 21
                    '    JewelImg = New Bitmap("Jewels\Purple_1.png")
                    'Case 22
                    '    JewelImg = New Bitmap("Jewels\Purple_2.png")
                    'Case 23
                    '    JewelImg = New Bitmap("Jewels\Purple_3.png")
                    'Case 24
                    '    JewelImg = New Bitmap("Jewels\Purple_4.png")
                    'Case 25
                    '    JewelImg = New Bitmap("Jewels\Purple_5.png")
                    'Case 26
                    '    JewelImg = New Bitmap("Jewels\Purple_6.png")
                    'Case 27
                    '    JewelImg = New Bitmap("Jewels\Purple_7.png")
                    'Case 28
                    '    JewelImg = New Bitmap("Jewels\Red_1.png")
                    'Case 29
                    '    JewelImg = New Bitmap("Jewels\Red_2.png")
                    'Case 30
                    '    JewelImg = New Bitmap("Jewels\Red_3.png")
                    'Case 31
                    '    JewelImg = New Bitmap("Jewels\Red_4.png")
                    'Case 32
                    '    JewelImg = New Bitmap("Jewels\Red_5.png")
                    'Case 33
                    '    JewelImg = New Bitmap("Jewels\Red_6.png")
                    'Case 34
                    '    JewelImg = New Bitmap("Jewels\Red_7.png")
                    'Case 35
                    '    JewelImg = New Bitmap("Jewels\Yellow_1.png")
                    'Case 36
                    '    JewelImg = New Bitmap("Jewels\Yellow_2.png")
                    'Case 37
                    '    JewelImg = New Bitmap("Jewels\Yellow_3.png")
                    'Case 38
                    '    JewelImg = New Bitmap("Jewels\Yellow_4.png")
                    'Case 39
                    '    JewelImg = New Bitmap("Jewels\Yellow_5.png")
                    'Case 40
                    '    JewelImg = New Bitmap("Jewels\Yellow_6.png")
                    'Case 41
                    '    JewelImg = New Bitmap("Jewels\Yellow_7.png")
                    'Case 42
                    '    JewelImg = New Bitmap("Jewels\Yellow_7.png")
            End Select
        End Sub
    End Class
    
    Public Class pbGrid
        Inherits PictureBox
    
    End Class
    

    Saturday, April 6, 2013 4:57 PM
  • Solved issue but have new issue in seperate post

    Public Class frmGame
        Dim Grid(10, 10) As pbGrid
        Dim RanJewel As Random
        Dim Jewel As Integer
        Dim JewelImg As String
        Dim TurnOffSleep As Boolean
    
        Dim JewelValue As Integer
        Dim MasterJewelValue As Integer
        Dim MasterJewelTicker As Integer = 8
    
        Dim PlyScore As Integer
    
        Private Sub frmGame_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim RunOnce As Boolean
    
            MasterJewelTimer.Start()
    
            GridValue()
            BuildGrid()
    
            If RunOnce = False Then
                RunOnce = True
                pbMasterJewel.BackgroundImage = Image.FromFile(JewelImg)
            End If
        End Sub
    
        Public Sub DrawGrid(ByVal row As Integer, ByVal column As Integer)
            GridValue()
            Grid(row, column) = New pbGrid
            Grid(row, column).Name = "pbGrid_" & row.ToString & "_" & column.ToString
            Grid(row, column).Size = New Point(50, 50)
            Grid(row, column).BorderStyle = BorderStyle.None
            Grid(row, column).BackColor = Color.Transparent
            Grid(row, column).BackgroundImage = Image.FromFile(JewelImg)
            Grid(row, column).BackgroundImageLayout = ImageLayout.Stretch
            Grid(row, column).Location = New Point((Grid(row, column).Width * column) + 413, (Grid(row, column).Height * row) + 85)
            Me.Controls.Add(Grid(row, column))
        End Sub
    
        Public Sub BuildGrid()
            For row = 0 To 10
                For column = 0 To 10
                    DrawGrid(row, column)
                Next
            Next
    
            'Stop Sleep
            TurnOffSleep = True
        End Sub
    
        Public Sub GridValue()
            RanJewel = New Random
            Jewel = RanJewel.Next(0, 42)
            Select Case Jewel
                Case 0
                    JewelImg = "Jewels\Blue\Blue_1.png"
                Case 1
                    JewelImg = "Jewels\Blue\Blue_2.png"
                Case 2
                    JewelImg = "Jewels\Blue\Blue_3.png"
                Case 3
                    JewelImg = "Jewels\Blue\Blue_4.png"
                Case 4
                    JewelImg = "Jewels\Blue\Blue_5.png"
                Case 5
                    JewelImg = "Jewels\Blue\Blue_6.png"
                Case 6
                    JewelImg = "Jewels\Blue\Blue_7.png"
                Case 7
                    JewelImg = "Jewels\Green\Green_1.png"
                Case 8
                    JewelImg = "Jewels\Green\Green_2.png"
                Case 9
                    JewelImg = "Jewels\Green\Green_3.png"
                Case 10
                    JewelImg = "Jewels\Green\Green_4.png"
                Case 11
                    JewelImg = "Jewels\Green\Green_5.png"
                Case 12
                    JewelImg = "Jewels\Green\Green_6.png"
                Case 13
                    JewelImg = "Jewels\Green\Green_7.png"
                Case 14
                    JewelImg = "Jewels\Grey\Grey_1.png"
                Case 15
                    JewelImg = "Jewels\Grey\Grey_2.png"
                Case 16
                    JewelImg = "Jewels\Grey\Grey_3.png"
                Case 17
                    JewelImg = "Jewels\Grey\Grey_4.png"
                Case 18
                    JewelImg = "Jewels\Grey\Grey_5.png"
                Case 19
                    JewelImg = "Jewels\Grey\Grey_6.png"
                Case 20
                    JewelImg = "Jewels\Grey\Grey_7.png"
                Case 21
                    JewelImg = "Jewels\Purple\Purple_1.png"
                Case 22
                    JewelImg = "Jewels\Purple\Purple_2.png"
                Case 23
                    JewelImg = "Jewels\Purple\Purple_3.png"
                Case 24
                    JewelImg = "Jewels\Purple\Purple_4.png"
                Case 25
                    JewelImg = "Jewels\Purple\Purple_5.png"
                Case 26
                    JewelImg = "Jewels\Purple\Purple_6.png"
                Case 27
                    JewelImg = "Jewels\Purple\Purple_7.png"
                Case 28
                    JewelImg = "Jewels\Red\Red_1.png"
                Case 29
                    JewelImg = "Jewels\Red\Red_2.png"
                Case 30
                    JewelImg = "Jewels\Red\Red_3.png"
                Case 31
                    JewelImg = "Jewels\Red\Red_4.png"
                Case 32
                    JewelImg = "Jewels\Red\Red_5.png"
                Case 33
                    JewelImg = "Jewels\Red\Red_6.png"
                Case 34
                    JewelImg = "Jewels\Red\Red_7.png"
                Case 35
                    JewelImg = "Jewels\Yellow\Yellow_1.png"
                Case 36
                    JewelImg = "Jewels\Yellow\Yellow_2.png"
                Case 37
                    JewelImg = "Jewels\Yellow\Yellow_3.png"
                Case 38
                    JewelImg = "Jewels\Yellow\Yellow_4.png"
                Case 39
                    JewelImg = "Jewels\Yellow\Yellow_5.png"
                Case 40
                    JewelImg = "Jewels\Yellow\Yellow_6.png"
                Case 41
                    JewelImg = "Jewels\Yellow\Yellow_7.png"
                Case 42
                    JewelImg = "Jewels\Yellow\Yellow_7.png"
            End Select
    
            'Helps Randomize
            If TurnOffSleep = False Then
                System.Threading.Thread.Sleep(12)
            End If
        End Sub
    
        Public Sub GridClick(ByVal sender As pbGrid, ByVal e As EventArgs)
            Select Case sender.Name
                Case "pbGrid_0_0"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_1"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_2"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_3"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_4"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_5"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_6"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_7"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_8"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_9"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
                Case "pbGrid_0_10"
                    If sender.BackgroundImage.ToString = pbMasterJewel.BackgroundImage.ToString Then
                        MsgBox("hit1")
                        GridValue()
                        sender.BackgroundImage = Image.FromFile(JewelImg)
                    Else
                        MsgBox("hit2")
                    End If
            End Select
        End Sub
    
        Private Sub MasterJewelTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MasterJewelTimer.Tick
            If MasterJewelTicker <= 0 Then
                MasterJewelTicker = 8
                GridValue()
                pbMasterJewel.BackgroundImage = Image.FromFile(JewelImg)
            Else
                MasterJewelTicker -= 1
            End If
        End Sub
    
        Private Sub LblScore_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblScore.TextChanged
            Dim x As Integer = 93
            Dim y As Integer = 371
            If PlyScore > 999999999 Then
                PlyScore = 999999999
            Else
                For Each lblScore.Text.ToCharArray() As Char() (+1 Overloads)
                    lblScore.Location = New Point((x - lblScore.Text.Length), y)
                Next
            End If
        End Sub
    End Class
    
    Public Class pbGrid
        Inherits PictureBox
    
        Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
            frmGame.GridClick(Me, e)
            MyBase.OnClick(e)
        End Sub
    End Class
    

    • Marked as answer by mholmes_3038 Saturday, April 6, 2013 6:12 PM
    Saturday, April 6, 2013 6:12 PM