-
okay heres the deal in the following code i want to be able to refer to an object from a string i built to specify the correct picture box
Private Sub Form_Load()
Box_Base_String = "Box_col"
Col = 1
Row = 1
While Col < 9
Box_Fill_String = Box_Base_String + Str(Col) + "_" + Str(Row)
Box_Fill_String LoadPicture(CurDir & "\grass_bg.gif")
<okay here is the spot i want the string Box_Fill_String 's value to be read as the object name can i do this>
If Row < 9 Then
Row = Row + 1
Else
Row = 1
Col = Col + 1
End If
Wend
End Sub
if anyone can help i would be very happy
i know this is most likly badly written code but i teach myself as i go so i think i do alright
so any help?
-
I don't believe you can do what you want, but one suggestion I can make is to change
Box_Fill_String = Box_Base_String + Str(Col) + "_" + Str(Row)
to
Box_Fill_String = Box_Base_String & Str(Col) & "_" & Str(Row)
While concatenating strings with "+" works most of the time, VB will, if it can, ADD the values.
-
I really don't understand what you are trying to do
what is this?
Box_Fill_String = Box_Base_String + Str(Col) + "_" + Str(Row)
'' I assume you mean ' = ' after Box_Fill_String
Box_Fill_String LoadPicture(CurDir & "\grass_bg.gif")
Box_Fill_String is a string not a picture object
as far as setting up a matrix... you should be able to index a linear array based on a 2D matrix as long as you know the width of the matrix.
ie:
assumes base 0 matrix
index = (X * MatrixWidth) + Y
(0,0) -> picture index 0
(0,1) -> picture index 1