Prince
Prince

Reputation: 31

Run-Time error '340' vb 6.0, Control Array Element '3' doesn't exist

Dim nPicture As Integer
For n = 1 To 4
    If p_strInstrument(n, 0) = "A" Then
        nPicture = (n * 4) + 1
    Else
        nPicture = (n * 4) + 4
    End If
    'How Can i edit the line below?
    frm_Experiment.picInstrument(n).Picture = frm_Experiment.ImageListInstrument.ListImages(nPicture).Picture
Next n

p_blnInstReady = True
'Unload Me
frm_SearchInstrument.WindowState = vbMinimized
frm_SearchInstrument.Visible = False

Upvotes: 0

Views: 4481

Answers (1)

BobRodes
BobRodes

Reputation: 6165

You're getting the error because you have an array of controls called picInstrument, none of which have an Index property that evaluates to 3. Check the Index property of each control in your array, and make sure that they go from 1 to 4 as does your For loop.

You're better off starting with 0, and going from 0 to 3 in your For loop, though.

Upvotes: 1

Related Questions