Program is attached as well, due to there being pictures of the ships that are required to get the full experience of the program

I am recreating battleship in Visual Basic 6, and I am almost complete. The one part that I am unable to complete, is matching an input value to the value of the picturebox. To better explain...

I have 100 Pictureboxes in a control array, and the ships are placed among the 100 spots based off of a generated number. Now, the program is singleplayer instead of multiplayer, so the objective of the game is to find the ships. In order to find the ships, the user is required to input the column value and a row value, which is added together to represent a picturebox in the array. For example, Column 4, row six would be i=53. From there, I wanted the program to use that to check the value of the picture1(i) to see if there was a small, medium, or large ship within that picturebox.

My problem is that I am having trouble matching the value that is inputted from the user to the picturebox in the array to check if any ship or part of a ship is in that picturebox. Also, if the user input value matches a picturebox that contains a piece of a ship, how do I eliminate all of the pieces of that ship?
Code Below

Dim placesmall, placemed, placebig As Integer 'ship placement
Dim row, column, spot As Integer 'Ship Guess
Dim i As Integer 'ship random spot

Private Sub Locate_Click()
r = 0 'Zero Values
column = 0 'Zero Values
column = InputBox("Guess the Column")
row = InputBox("Guess the Row")
'Choose the row for the ship location guess
    row = (row * 10) - 10
    column = column - 1
i = row + column


End Sub

Private Sub placeship_Click()
'clear the pictureboxes
For i = 0 To 99
Picture1(i).Cls
Next i

'Small ship
placesmall = Int(99 * Rnd + 1)
i = placesmall
    i = 0
    i = Int(99 * Rnd + 1)
Picture1(i) = LoadPicture(App.Path & "/ss1.jpg")
    i = i + 1
Picture1(i) = LoadPicture(App.Path & "/ss2.jpg")

'medium ship
placemed = Int(99 * Rnd + 1)
If placemed = placesmall Or placemed = placesmall + 1 Then 'If the ship is placed over another ship, then it must respot itself
    placemed = 0
    placemed = Int(99 * Rnd + 1)
End If


'Test if ship is going to overlap to the next line

i = placemed
If i = 8 Or 18 Or 28 Or 38 Or 48 Or 58 Or 68 Or 78 Or 88 Or 98 Then
        i = 0
            i = Int(99 * Rnd + 1)
End If
If i = 9 Or 19 Or 29 Or 39 Or 49 Or 59 Or 69 Or 79 Or 89 Or 99 Then
    i = 0
        i = Int(99 * Rnd + 1)
End If


'Print The Ship

Picture1(i) = LoadPicture(App.Path & "/ms1.jpg")
    i = i + 1
Picture1(i) = LoadPicture(App.Path & "/ms2.jpg")
    i = i + 1
Picture1(i) = LoadPicture(App.Path & "/ms3.jpg")

'large ship
placebig = Int(99 * Rnd + 1)
If placebig = placesmall Or placebig = placemed Or placebig = placesmall + 1 Or placebig = placemed + 1 Or placebig = placemed + 2 Then 'If the ship is placed over another ship, then it must respot itself
    placebig = Int(99 * Rnd + 1)
End If
i = placebig

'Stop ship from printing to next line

If i = 7 Or 17 Or 27 Or 37 Or 47 Or 57 Or 67 Or 77 Or 87 Or 97 Then
    i = 0
        i = Int(99 * Rnd + 1)
End If
If i = 8 Or 18 Or 28 Or 38 Or 48 Or 58 Or 68 Or 78 Or 88 Or 98 Then
        i = 0
            i = Int(99 * Rnd + 1)
End If
If i = 9 Or 19 Or 29 Or 39 Or 49 Or 59 Or 69 Or 79 Or 89 Or 99 Then
    i = 0
        i = Int(99 * Rnd + 1)
End If



'Print The Ship

Picture1(i) = LoadPicture(App.Path & "/bs1.jpg")
    i = i + 1
Picture1(i) = LoadPicture(App.Path & "/bs2.jpg")
    i = i + 1
Picture1(i) = LoadPicture(App.Path & "/bs3.jpg")
    i = i + 1
Picture1(i) = LoadPicture(App.Path & "/bs4.jpg")


'For i = 0 To 99
'Picture1(i) = Nothing
'Next i

End Sub


Private Sub quit_Click()
End
End Sub

Thank You for time.

Once a picture is placed in the picture box it has no memory where it came from or what its name is. What you can do is using the tag property of the picture box.Something like:

Picture1(i) = LoadPicture(App.Path & "/ms1.jpg")
Picture1(i).Tag=Filename

This way you can refere to the tag property to get he picture name that is in the picture box

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.