Results 1 to 2 of 2

Thread: Can I create an object during run time?

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    2

    Question

    I want to create a large number of image objects a loop. I could do this in design time but it seems like I should be able to do something like this:

    Loop
    imgBall(i).Picture="C:\Ball.jpg"
    imgBall(i).Top=7000
    i=i+1
    Until i= a large number


    Any help would be great

    Thanks Mike


  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Option Explicit
    
    'create a bunch of image boxes with a picture in it.
    
    Private Sub Command1_Click()
    
    Dim MaxId As Integer
    MaxId = 4
       Dim i
       For i = 1 To MaxId
       Load Image1(i)
       
       ' Set new button under previous button.
       Image1(i).Top = Image1(i - 1).Top + 200
       Image1(i).Left = Image1(i - 1).Left + 800
       Image1(i).Visible = True  ' Display new
                                     ' button.
       Image1(i).Picture = LoadPicture("C:\a wayne\dirtbagdog.gif")
       
       Next i
    End Sub
    
    'the image buttons are removed by the Click event
    'procedure for the Delete command button (Command2)
    
    Private Sub Command2_Click()
     For i = 1 To MaxId
       If MaxId < 1 Then Exit Sub   ' Keep first buttons.
       Unload Image1(i)          ' Delete last button.
       MaxId = MaxId - 1            ' Decrement button count.
       Image1(0).SetFocus       ' Reset button selection.
       Image1(0).Width = 4000
    
    Next
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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