Ok, So i wrote this basic program that takes a map file as an input, and parses it and then draws the map. Its sort of like VERY BASIC tile mapping. The problem is,

I cant think of a way to loop it so that no matter how many map cells are defined in the file, it will work.

Right now i have if then else checks for how many are there, and it works, but its limited to 10 due to the size of the code, and its getting LONG.

Is there any way for me to shorten this up and make it easier?

Here is the code:

Public Class Form1
    'Defining the drawing variables, rectangles, bitmaps, etc.
    'For drawing both the map grid and the backgrounds/icons
    Private rect As Rectangle
    Private rect2 As Rectangle
    Private Draw As Graphics
    Private Draw2 As Graphics
    Private bitmap As Bitmap = New Bitmap(5, 5)
    'bitmap variables for each icon that can be displayed
    Dim tree As Bitmap = New Bitmap(filename:="C:\dell\tree.gif")
    Dim boulder As Bitmap = New Bitmap(filename:="C:\dell\boulder.gif")
    Dim bush As Bitmap = New Bitmap(filename:="C:\dell\bush.gif")
    Dim power As Bitmap = New Bitmap(filename:="C:\dell\power.gif")
    Dim treasure As Bitmap = New Bitmap(filename:="C:\dell\treasure.gif")
    Dim diamonds As Bitmap = New Bitmap(filename:="C:\dell\diamond.gif")
    Dim hatchet As Bitmap = New Bitmap(filename:="C:\dell\hatchet.gif")
    Dim axe As Bitmap = New Bitmap(filename:="C:\dell\axe.gif")
    Dim chainsaw As Bitmap = New Bitmap(filename:="C:\dell\chainsaw.gif")
    Dim chisel As Bitmap = New Bitmap(filename:="C:\dell\chisel.gif")
    Dim sledge As Bitmap = New Bitmap(filename:="C:\dell\sledge.gif")
    Dim jackhammer As Bitmap = New Bitmap(filename:="C:\dell\jackhammer.gif")
    Dim machete As Bitmap = New Bitmap(filename:="C:\dell\machete.gif")
    Dim binoculars As Bitmap = New Bitmap(filename:="C:\dell\binoculars.gif")
    Dim hero As Bitmap = New Bitmap(filename:="C:\dell\hero.gif")
    'Variable defined to read the file
    Dim fileReader As System.IO.StreamReader
    'Various variables for the data storage
    Dim HeroLocation, MapName, WhiffelBalance, EnergyBalance, Garbage, EnergyBal, WhiffelBal, Temp As String
    Dim MapItems(20), Inventory(20) As String
    Dim numgrid, HeroLo1, HeroLo2, i As Integer
    Dim Item1 As New ListViewItem
    Dim CellID(), CellID2(), CellID3(), CellID4(), CellID5(), CellID6(), CellID7(), CellID8(), CellID9(), CellID10() As String
    Dim CellID11(), CellID12(), CellID13(), CellID14(), CellID15(), CellID16(), CellID17(), CellID18(), CellID19(), CellID20() As String
    'Event Handler for the "Load Map" Button Click
    Private Sub Map_Load_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Map_Load_Button.Click
        'Setup for the List View that displays the inventory
        InventoryView.View = View.Details
        InventoryView.Columns.Add("Tool", 76)
        'Read in the file and populate the text boxes
        fileReader = My.Computer.FileSystem.OpenTextFileReader(Map_File_Input.Text)
        MapName = fileReader.ReadLine()
        Map_Name_Text_Box.Text = MapName
        numgrid = fileReader.ReadLine()
        Garbage = fileReader.ReadLine()
        HeroLocation = fileReader.ReadLine()
        EnergyBal = fileReader.ReadLine()
        WhiffelBal = fileReader.ReadLine()
        'Parse the hero location from the text file, store in Int variables
        HeroLo1 = HeroLocation(0) & HeroLocation(1)
        HeroLo2 = HeroLocation(3) & HeroLocation(4)
        'Populate the balance of the energy and whiffle accounts
        Energy_Balance_Box.Text = EnergyBal
        Whiffel_Balance_Box.Text = WhiffelBal
        'Read in the next line (Inventory)
        Inventory(i) = fileReader.ReadLine()
        'Store the first inventory item as a temp variable (for comparison in the loop)
        Temp = Inventory(i)
        'Increment i
        i = i + 1
        'variable as a new list item
        Dim mitem As New ListViewItem
        'set this item to the first inventory item
        mitem.Text = Temp
        'Add to the list view
        InventoryView.Items.Add(mitem)
        'Loop for reading the rest of the inventory
        While System.String.Compare(Temp, "#########################") <> 0
            Inventory(i) = fileReader.ReadLine()
            If System.String.Compare(Inventory(i), "#########################") <> 0 Then
                Dim litem As New ListViewItem
                litem.Text = Inventory(i)
                InventoryView.Items.Add(litem)
            End If
            Temp = Inventory(i)
            i = i + 1
        End While

        i = 0 'reset i to 0
        Temp = fileReader.ReadLine() ' Read the next line into temp
        MapItems(i) = Temp ' set the first item of MapItems to the Temp
        While System.String.Compare(Temp, "") > 0 'loop for reading the rest of the map items
            i += 1 'increment i
            MapItems(i) = fileReader.ReadLine() 'read in next line
            Temp = MapItems(i) 'reset temp
        End While

        If i > 10 Then 'checks to see if there are more than 10 pre defined map cells
            MsgBox("This version only supports a maximum of 10 pre-defined map cells")
            Return
        End If
        'Lots of conditionals for the number of items that could be in the map file
        'Each conditional splits the items into 4 different strings, where they are deliminated by a comma in the map file
        If i = 0 Then
        End If
        If i = 1 Then
            CellID = MapItems(0).Split(",")
        End If
        If i = 2 Then
            CellID = MapItems(0).Split(",")
            CellID2 = MapItems(1).Split(",")
        End If
        If i = 3 Then
            CellID = MapItems(0).Split(",")
            CellID2 = MapItems(1).Split(",")
            CellID3 = MapItems(2).Split(",")
        End If
        If i = 4 Then
            CellID = MapItems(0).Split(",")
            CellID2 = MapItems(1).Split(",")
            CellID3 = MapItems(2).Split(",")
            CellID4 = MapItems(3).Split(",")
        End If
        If i = 5 Then
            CellID = MapItems(0).Split(",")
            CellID2 = MapItems(1).Split(",")
            CellID3 = MapItems(2).Split(",")
            CellID4 = MapItems(3).Split(",")
            CellID5 = MapItems(4).Split(",")
        End If
        If i = 6 Then
            CellID = MapItems(0).Split(",")
            CellID2 = MapItems(1).Split(",")
            CellID3 = MapItems(2).Split(",")
            CellID4 = MapItems(3).Split(",")
            CellID5 = MapItems(4).Split(",")
            CellID6 = MapItems(5).Split(",")
        End If
        If i = 7 Then
            CellID = MapItems(0).Split(",")
            CellID2 = MapItems(1).Split(",")
            CellID3 = MapItems(2).Split(",")
            CellID4 = MapItems(3).Split(",")
            CellID5 = MapItems(4).Split(",")
            CellID6 = MapItems(5).Split(",")
            CellID7 = MapItems(6).Split(",")
        End If
        If i = 8 Then
            CellID = MapItems(0).Split(",")
            CellID2 = MapItems(1).Split(",")
            CellID3 = MapItems(2).Split(",")
            CellID4 = MapItems(3).Split(",")
            CellID5 = MapItems(4).Split(",")
            CellID6 = MapItems(5).Split(",")
            CellID7 = MapItems(6).Split(",")
            CellID8 = MapItems(7).Split(",")
        End If
        If i = 9 Then
            CellID = MapItems(0).Split(",")
            CellID2 = MapItems(1).Split(",")
            CellID3 = MapItems(2).Split(",")
            CellID4 = MapItems(3).Split(",")
            CellID5 = MapItems(4).Split(",")
            CellID6 = MapItems(5).Split(",")
            CellID7 = MapItems(6).Split(",")
            CellID8 = MapItems(7).Split(",")
            CellID9 = MapItems(8).Split(",")
        End If
        If i = 10 Then
            CellID = MapItems(0).Split(",")
            CellID2 = MapItems(1).Split(",")
            CellID3 = MapItems(2).Split(",")
            CellID4 = MapItems(3).Split(",")
            CellID5 = MapItems(4).Split(",")
            CellID6 = MapItems(5).Split(",")
            CellID7 = MapItems(6).Split(",")
            CellID8 = MapItems(7).Split(",")
            CellID9 = MapItems(8).Split(",")
            CellID10 = MapItems(9).Split(",")
        End If

    End Sub
    'Event handler for the Setup_Map Button
    Private Sub SetupToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SetupToolStripMenuItem.Click
        'Set window to maximize
        Me.WindowState = FormWindowState.Maximized
        'For loop to draw the map!
        For tilex = 1 To numgrid 'tile in the x direction the number of boxes in the grid
            For tiley = 1 To numgrid + 1 'tile in the y direction the number of boxes in the grid (+1 due to nested loop)
                rect = New Rectangle(tilex * 12, tiley * 12, 12, 12) 'define new rectangle
                Draw = Graphics.FromHwnd(Me.Handle)
                'Define a drawer
                'Draw the main grid of rectangles
                Draw.DrawRectangle(Pens.Ivory, rect)
                'Locate the hero and draw the hero icon
                If tilex = HeroLo1 And tiley = (HeroLo2 + 1) Then
                    Draw.DrawImage(image:=hero, rect:=rect)
                End If
                'Lots of conditionals that are dependant on how many cells are predefined (up to 10), locates all the elements
                'and draws them on the grid.
                If i = 0 Then
                End If

                If i = 1 Then
                    If tilex = CellID(0) And tiley = CellID(1) And CellID(2) = 1 Then
                        If System.String.Compare(CellID(4), "None") = 0 Then
                            If CellID(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If

                    End If
                End If

                If i = 2 Then
                    If tilex = CellID(0) And tiley = CellID(1) And CellID(2) = 1 Then
                        If System.String.Compare(CellID(4), "None") = 0 Then
                            If CellID(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If

                    End If
                    If tilex = CellID2(0) And tiley = CellID2(1) And CellID2(2) = 1 Then
                        If System.String.Compare(CellID2(4), "None") = 0 Then
                            If CellID2(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID2(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID2(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID2(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID2(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                End If

                If i = 3 Then
                    If tilex = CellID(0) And tiley = CellID(1) And CellID(2) = 1 Then
                        If System.String.Compare(CellID(4), "None") = 0 Then
                            If CellID(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If

                    End If
                    If tilex = CellID2(0) And tiley = CellID2(1) And CellID2(2) = 1 Then
                        If System.String.Compare(CellID2(4), "None") = 0 Then
                            If CellID2(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID2(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID2(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID2(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID2(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                    If tilex = CellID3(0) And tiley = CellID3(1) And CellID3(2) = 1 Then
                        If System.String.Compare(CellID3(4), "None") = 0 Then
                            If CellID3(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID3(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID3(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID3(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID3(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                End If

                If i = 4 Then
                    If tilex = CellID(0) And tiley = CellID(1) And CellID(2) = 1 Then
                        If System.String.Compare(CellID(4), "None") = 0 Then
                            If CellID(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If

                    End If
                    If tilex = CellID2(0) And tiley = CellID2(1) And CellID2(2) = 1 Then
                        If System.String.Compare(CellID2(4), "None") = 0 Then
                            If CellID2(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID2(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID2(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID2(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID2(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                    If tilex = CellID3(0) And tiley = CellID3(1) And CellID3(2) = 1 Then
                        If System.String.Compare(CellID3(4), "None") = 0 Then
                            If CellID3(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID3(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID3(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID3(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID3(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                    If tilex = CellID4(0) And tiley = CellID4(1) And CellID4(2) = 1 Then
                        If System.String.Compare(CellID4(4), "None") = 0 Then
                            If CellID4(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID4(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID4(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID4(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID4(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                End If

                If i = 5 Then
                    If tilex = CellID(0) And tiley = CellID(1) And CellID(2) = 1 Then
                        If System.String.Compare(CellID(4), "None") = 0 Then
                            If CellID(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If

                    End If
                    If tilex = CellID2(0) And tiley = CellID2(1) And CellID2(2) = 1 Then
                        If System.String.Compare(CellID2(4), "None") = 0 Then
                            If CellID2(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID2(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID2(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID2(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID2(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                    If tilex = CellID3(0) And tiley = CellID3(1) And CellID3(2) = 1 Then
                        If System.String.Compare(CellID3(4), "None") = 0 Then
                            If CellID3(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID3(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID3(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID3(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID3(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                    If tilex = CellID4(0) And tiley = CellID4(1) And CellID4(2) = 1 Then
                        If System.String.Compare(CellID4(4), "None") = 0 Then
                            If CellID4(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID4(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID4(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID4(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID4(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                    If tilex = CellID5(0) And tiley = CellID5(1) And CellID5(2) = 1 Then
                        If System.String.Compare(CellID5(4), "None") = 0 Then
                            If CellID5(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID5(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID5(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID5(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID5(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                End If
                If i = 6 Then
                    If tilex = CellID(0) And tiley = CellID(1) And CellID(2) = 1 Then
                        If System.String.Compare(CellID(4), "None") = 0 Then
                            If CellID(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If

                    End If
                    If tilex = CellID2(0) And tiley = CellID2(1) And CellID2(2) = 1 Then
                        If System.String.Compare(CellID2(4), "None") = 0 Then
                            If CellID2(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID2(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID2(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID2(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID2(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                    If tilex = CellID3(0) And tiley = CellID3(1) And CellID3(2) = 1 Then
                        If System.String.Compare(CellID3(4), "None") = 0 Then
                            If CellID3(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID3(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID3(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID3(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID3(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                    If tilex = CellID4(0) And tiley = CellID4(1) And CellID4(2) = 1 Then
                        If System.String.Compare(CellID4(4), "None") = 0 Then
                            If CellID4(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID4(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID4(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID4(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID4(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                    If tilex = CellID5(0) And tiley = CellID5(1) And CellID5(2) = 1 Then
                        If System.String.Compare(CellID5(4), "None") = 0 Then
                            If CellID5(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID5(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID5(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID5(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID5(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                    If tilex = CellID6(0) And tiley = CellID6(1) And CellID6(2) = 1 Then
                        If System.String.Compare(CellID6(4), "None") = 0 Then
                            If CellID6(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID6(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID6(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID6(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID6(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID6(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID6(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID6(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID6(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID6(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID6(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID6(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID6(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID6(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID6(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID6(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID6(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID6(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                End If
                If i = 7 Then
                    If tilex = CellID(0) And tiley = CellID(1) And CellID(2) = 1 Then
                        If System.String.Compare(CellID(4), "None") = 0 Then
                            If CellID(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If

                    End If
                    If tilex = CellID2(0) And tiley = CellID2(1) And CellID2(2) = 1 Then
                        If System.String.Compare(CellID2(4), "None") = 0 Then
                            If CellID2(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID2(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID2(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID2(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID2(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID2(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                    If tilex = CellID3(0) And tiley = CellID3(1) And CellID3(2) = 1 Then
                        If System.String.Compare(CellID3(4), "None") = 0 Then
                            If CellID3(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID3(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID3(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID3(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID3(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID3(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                    If tilex = CellID4(0) And tiley = CellID4(1) And CellID4(2) = 1 Then
                        If System.String.Compare(CellID4(4), "None") = 0 Then
                            If CellID4(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID4(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID4(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID4(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID4(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID4(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                    If tilex = CellID5(0) And tiley = CellID5(1) And CellID5(2) = 1 Then
                        If System.String.Compare(CellID5(4), "None") = 0 Then
                            If CellID5(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID5(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellID5(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellID5(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellID5(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellID5(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If
                    End If
                    If tilex = CellID6(0) And tiley = CellID6(1) And CellID6(2) = 1 Then
                        If System.String.Compare(CellID6(4), "None") = 0 Then
                            If CellID6(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellID6(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, re

Edited 5 Years Ago by Catalyst.X: Tags

3400 lines of code is a bit much to tackle all at once.
Why don't you take a section (let's say one function), separate it into a new .VB file all by itself, then refactor that into smaller functions grouped by functionality THEN optimize the code.

Once you're looking at smaller portions, some optimizations will seem obvious and will be manageable.

Right now, it's too much.

Edited 5 Years Ago by thines01: typo

Ok so I got it to how I think it SHOULD work. But I get a null reference error at line 91. AND i think it has something to do with my declaration of the CellIDArray on line 32. I am having a problem working with the 2D Array.

Public Class Form1
    'Defining the drawing variables, rectangles, bitmaps, etc.
    'For drawing both the map grid and the backgrounds/icons
    Private rect As Rectangle
    Private rect2 As Rectangle
    Private Draw As Graphics
    Private Draw2 As Graphics
    Private bitmap As Bitmap = New Bitmap(5, 5)
    'bitmap variables for each icon that can be displayed
    Dim tree As Bitmap = New Bitmap(filename:="C:\dell\tree.gif")
    Dim boulder As Bitmap = New Bitmap(filename:="C:\dell\boulder.gif")
    Dim bush As Bitmap = New Bitmap(filename:="C:\dell\bush.gif")
    Dim power As Bitmap = New Bitmap(filename:="C:\dell\power.gif")
    Dim treasure As Bitmap = New Bitmap(filename:="C:\dell\treasure.gif")
    Dim diamonds As Bitmap = New Bitmap(filename:="C:\dell\diamond.gif")
    Dim hatchet As Bitmap = New Bitmap(filename:="C:\dell\hatchet.gif")
    Dim axe As Bitmap = New Bitmap(filename:="C:\dell\axe.gif")
    Dim chainsaw As Bitmap = New Bitmap(filename:="C:\dell\chainsaw.gif")
    Dim chisel As Bitmap = New Bitmap(filename:="C:\dell\chisel.gif")
    Dim sledge As Bitmap = New Bitmap(filename:="C:\dell\sledge.gif")
    Dim jackhammer As Bitmap = New Bitmap(filename:="C:\dell\jackhammer.gif")
    Dim machete As Bitmap = New Bitmap(filename:="C:\dell\machete.gif")
    Dim binoculars As Bitmap = New Bitmap(filename:="C:\dell\binoculars.gif")
    Dim hero As Bitmap = New Bitmap(filename:="C:\dell\hero.gif")
    'Variable defined to read the file
    Dim fileReader As System.IO.StreamReader
    'Various variables for the data storage
    Dim HeroLocation, MapName, WhiffelBalance, EnergyBalance, Garbage, EnergyBal, WhiffelBal, Temp As String
    Dim MapItems(20), Inventory(20) As String
    Dim numgrid, HeroLo1, HeroLo2, i As Integer
    Dim Item1 As New ListViewItem
    Dim CellIDArray()() As String
    
    'Event Handler for the "Load Map" Button Click
    Private Sub Map_Load_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Map_Load_Button.Click
        'Setup for the List View that displays the inventory
        InventoryView.View = View.Details
        InventoryView.Columns.Add("Tool", 76)
        'Read in the file and populate the text boxes
        fileReader = My.Computer.FileSystem.OpenTextFileReader(Map_File_Input.Text)
        MapName = fileReader.ReadLine()
        Map_Name_Text_Box.Text = MapName
        numgrid = fileReader.ReadLine()
        Garbage = fileReader.ReadLine()
        HeroLocation = fileReader.ReadLine()
        EnergyBal = fileReader.ReadLine()
        WhiffelBal = fileReader.ReadLine()
        'Parse the hero location from the text file, store in Int variables
        HeroLo1 = HeroLocation(0) & HeroLocation(1)
        HeroLo2 = HeroLocation(3) & HeroLocation(4)
        'Populate the balance of the energy and whiffle accounts
        Energy_Balance_Box.Text = EnergyBal
        Whiffel_Balance_Box.Text = WhiffelBal
        'Read in the next line (Inventory)
        Inventory(i) = fileReader.ReadLine()
        'Store the first inventory item as a temp variable (for comparison in the loop)
        Temp = Inventory(i)
        'Increment i
        i = i + 1
        'variable as a new list item
        Dim mitem As New ListViewItem
        'set this item to the first inventory item
        mitem.Text = Temp
        'Add to the list view
        InventoryView.Items.Add(mitem)
        'Loop for reading the rest of the inventory
        While System.String.Compare(Temp, "#########################") <> 0
            Inventory(i) = fileReader.ReadLine()
            If System.String.Compare(Inventory(i), "#########################") <> 0 Then
                Dim litem As New ListViewItem
                litem.Text = Inventory(i)
                InventoryView.Items.Add(litem)
            End If
            Temp = Inventory(i)
            i = i + 1
        End While

        i = 0 'reset i to 0
        Temp = fileReader.ReadLine() ' Read the next line into temp
        MapItems(i) = Temp ' set the first item of MapItems to the Temp
        While System.String.Compare(Temp, "") > 0 'loop for reading the rest of the map items
            i += 1 'increment i
            MapItems(i) = fileReader.ReadLine() 'read in next line
            Temp = MapItems(i) 'reset temp
        End While
        'Lots of conditionals for the number of items that could be in the map file
        'Each conditional splits the items into 4 different strings, where they are deliminated by a comma in the map file


        For x As Integer = 0 To i - 1
            CellIDArray(x) = MapItems(x).Split(",")
        Next x


    End Sub
    'Event handler for the Setup_Map Button
    Private Sub SetupToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SetupToolStripMenuItem.Click
        'Set window to maximize
        Me.WindowState = FormWindowState.Maximized
        'For loop to draw the map!
        For tilex = 1 To numgrid 'tile in the x direction the number of boxes in the grid
            For tiley = 1 To numgrid + 1 'tile in the y direction the number of boxes in the grid (+1 due to nested loop)
                rect = New Rectangle(tilex * 12, tiley * 12, 12, 12) 'define new rectangle
                Draw = Graphics.FromHwnd(Me.Handle)
                'Define a drawer
                'Draw the main grid of rectangles
                Draw.DrawRectangle(Pens.Ivory, rect)
                'Locate the hero and draw the hero icon
                If tilex = HeroLo1 And tiley = (HeroLo2 + 1) Then
                    Draw.DrawImage(image:=hero, rect:=rect)
                End If


                For index As Integer = 1 To i
                    If tilex = CellIDArray(index)(0) And tiley = CellIDArray(index)(1) And CellIDArray(index)(2) = 1 Then
                        If System.String.Compare(CellIDArray(index)(4), "None") = 0 Then
                            If CellIDArray(index)(3) = 0 Then
                                Draw.FillRectangle(Brushes.YellowGreen, rect)
                            End If
                            If CellIDArray(index)(3) = 1 Then
                                Draw.FillRectangle(Brushes.ForestGreen, rect)
                            End If
                            If CellIDArray(index)(3) = 2 Then
                                Draw.FillRectangle(Brushes.Blue, rect)
                            End If
                            If CellIDArray(index)(3) = 3 Then
                                Draw.FillRectangle(Brushes.Black, rect)
                            End If
                        End If
                        If System.String.Compare(CellIDArray(index)(4), "Tree") = 0 Then
                            Draw.DrawImage(image:=tree, rect:=rect)
                        End If
                        If System.String.Compare(CellIDArray(index)(4), "Boulder") = 0 Then
                            Draw.DrawImage(image:=boulder, rect:=rect)
                        End If
                        If System.String.Compare(CellIDArray(index)(4), "Blackberry Bushes") = 0 Then
                            Draw.DrawImage(image:=bush, rect:=rect)
                        End If
                        If System.String.Compare(CellIDArray(index)(4), "Power Bar") = 0 Then
                            Draw.DrawImage(image:=power, rect:=rect)
                        End If
                        If System.String.Compare(CellIDArray(index)(4), "Treasure Chest") = 0 Then
                            Draw.DrawImage(image:=treasure, rect:=rect)
                        End If
                        If System.String.Compare(CellIDArray(index)(4), "Royal Diamonds") = 0 Then
                            Draw.DrawImage(image:=diamonds, rect:=rect)
                        End If
                        If System.String.Compare(CellIDArray(index)(4), "Hatchet") = 0 Then
                            Draw.DrawImage(image:=hatchet, rect:=rect)
                        End If
                        If System.String.Compare(CellIDArray(index)(4), "Axe") = 0 Then
                            Draw.DrawImage(image:=axe, rect:=rect)
                        End If
                        If System.String.Compare(CellIDArray(index)(4), "Chainsaw") = 0 Then
                            Draw.DrawImage(image:=chainsaw, rect:=rect)
                        End If
                        If System.String.Compare(CellIDArray(index)(4), "Chisel") = 0 Then
                            Draw.DrawImage(image:=chisel, rect:=rect)
                        End If
                        If System.String.Compare(CellIDArray(index)(4), "Sledge") = 0 Then
                            Draw.DrawImage(image:=sledge, rect:=rect)
                        End If
                        If System.String.Compare(CellIDArray(index)(4), "Jackhammer") = 0 Then
                            Draw.DrawImage(image:=jackhammer, rect:=rect)
                        End If
                        If System.String.Compare(CellIDArray(index)(4), "Machete") = 0 Then
                            Draw.DrawImage(image:=machete, rect:=rect)
                        End If
                        If System.String.Compare(CellIDArray(index)(4), "Binoculars") = 0 Then
                            Draw.DrawImage(image:=binoculars, rect:=rect)
                        End If

                    End If
                Next index

            Next
        Next

    End Sub

    Private Sub Browse_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Browse_Button.Click
        Using OpenFile As New OpenFileDialog
            OpenFile.Filter = "Text Files (*.txt)|*.txt"
            OpenFile.Title = "Select File"
            If OpenFile.ShowDialog() = Windows.Forms.DialogResult.OK Then
                MessageBox.Show("You selected " & OpenFile.FileName)
                Map_File_Input.Text = OpenFile.FileName
            End If
        End Using
    End Sub

End Class

.not tested, though I hope it helps.

Public Class Form1
    Private CellID1(), CellID2(), CellID3(), CellID4(), CellID5(), CellID6(), CellID7(), CellID8(), CellID9(), CellID10() As String
    Private MapItems(20) As String
    Private i As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Select Case i
            Case 0
                setCells(New Array() {CellID1, CellID2, CellID3}, New Integer() {1, 2, 3})
            Case 1
                setCells(New Array() {CellID4, CellID5, CellID6}, New Integer() {4, 5, 6})
            Case Else
                MsgBox(".hope and live to never Not.hope.", MsgBoxStyle.Information)
        End Select
    End Sub

    Private Sub setCells(ByVal selCells() As Array, ByVal selMapItems() As Integer)
        For i As Integer = 0 To selCells.Length - 1
            selCells(i) = MapItems(selMapItems(i)).Split(","c)
        Next
    End Sub
End Class

Edited 5 Years Ago by codeorder: n/a

This question has already been answered. Start a new discussion instead.