Results 1 to 3 of 3

Thread: [RESOLVED] help with runtime error 91

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Resolved [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:
    1. Debug.Print (picBatch(i).Name & vbCrLf)


    that is within this code

    vb Code:
    1. Dim i As Integer
    2. For i = 1 To intControlIndex
    3. Debug.Print (picBatch(i).Name & vbCrLf)
    4. Next i

    I also get it here


    vb Code:
    1. For Index = 1 To UBound(picBatch) Step 1 'as Variant  in picbatch
    2.       For i = 1 To intControlIndex Step 1
    3.         If picBatch(Index).Left = picBatch(i).Left Then
    4.             MsgBox ("We have collided" & picBatch(Index).Name)
    5.     End If
    6.     Next i
    7. Next Index

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    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:
    1. 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:
    1. ReDim picBatch(intControlIndex)


    I forgot to add the preserve..

    so it is now

    vb Code:
    1. ReDim Preserve picBatch(intControlIndex)

    just weird it didn't error on that line instead.

    however thread resolved thank you for your reply

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width