Results 1 to 2 of 2

Thread: can a control array be created on the fly?

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    sebasopol california
    Posts
    2
    Open "C:\PicView\Collections\FastLoadExp.txt" For Input As #1

    j1 = 0
    Do Until EOF(1) = True

    Input #1, s1

    ReDim Preserve pic(j1 + 1)

    Set pic(j1) = New Picture1

    pic(j1).Picture = LoadPicture(s1)
    pic(j1).Visible = False
    ...

    question:
    why would the SET, NEW statements create an arror like
    "user defined type not defined" ?
    the pic() variable is a global that is of type PictureBox

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    If you create the Picturebox as a Control Array (Set the controls Index property to Zero) then you can add to it at runtime, i.e.[CODE]Private Sub Command1_Click()
    Dim iFile As Integer
    Dim sFile As String

    iFile = FreeFile
    Open "C:\PicView\Collections\FastLoadExp.txt" For Input #iFile
    While Not EOF(iFile)
    Input #iFile, sFile
    Load Pictureboxes(Pictureboxes.Count)
    With Pictureboxes(Pictureboxes.Count - 1)
    .Visible = True
    .Move .Width * .Count, 0
    .Picture = LoadPicture(sFile)
    End With
    Wend
    Close iFile
    End Sub[CODE]

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