[RESOLVED] help with runtime error 91
I get a runtime error number 91: Object variable or With Block variable not set when running this line of code
vb Code:
Debug.Print (picBatch(i).Name & vbCrLf)
that is within this code
vb Code:
Dim i As Integer
For i = 1 To intControlIndex
Debug.Print (picBatch(i).Name & vbCrLf)
Next i
I also get it here
vb Code:
For Index = 1 To UBound(picBatch) Step 1 'as Variant in picbatch
For i = 1 To intControlIndex Step 1
If picBatch(Index).Left = picBatch(i).Left Then
MsgBox ("We have collided" & picBatch(Index).Name)
End If
Next i
Next Index
Re: help with runtime error 91
picBatch(i).Name tells me that there must be control array (probably of pictureboxes based on the control's name) of something named picBatch.
So, here is the question: do you really have control array named picBatch?
btw, picBatch(i).Name is really pointless statement because name is known and it is picBatch.
Re: help with runtime error 91
but it's not pointless... atleast I would like to not think so. what im doing is creating picture box controls on start-up each control is made by this command
vb Code:
Set picBatch(intControlIndex) = Controls.Add("VB.PictureBox", "PicBatch_" & CStr(intControlIndex))
each time it creates a control it names it as picbatch_1 or 2 or 3 so on and so forth.
however error was being caused because of this
vb Code:
ReDim picBatch(intControlIndex)
I forgot to add the preserve..
so it is now
vb Code:
ReDim Preserve picBatch(intControlIndex)
just weird it didn't error on that line instead.
however thread resolved thank you for your reply