Results 1 to 6 of 6

Thread: Creating PictureBoxes as run time???

  1. #1
    Guest

    Question

    Hi all.

    Is it possible to create new instances of a PictureBox? Like you do for a Form?

    I tried the following code:
    Code:
    Dim Pic as PictureBox 'That works well
    Set Pic = New PictureBox 'That does not work at all!
    What am I doing wrong here?

    Thanks.

  2. #2
    New Member
    Join Date
    Oct 2000
    Location
    Kuala Lumpur
    Posts
    4
    The first line is enough. No need the second line. TQ
    -oHmHaLiA-

  3. #3
    Guest

    It does not seem to work...

    I tried it, and it doesn't create a PictureBox, it creates a "pointer" to a picturebox pointing on "Nothing". So when entering:

    Code:
    pic(i).Scalewidth  = 100 'for example
    I get the following error:

    "Object variable or With Block variable not set."


    Any suggestions?





  4. #4
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625

    Cool I had the exact same problem in a different thread

    What you do is...

    First you create a picturebox and name it picNameOfPic (or whatever)

    and you set the Index value to 0 and set the visibility to true(at design time)

    then you put the following code in your program...

    Code:
    Dim i As Integer
    
    For i = 0 to 10
        'Note that picNameOfPic(0) is already loaded and thus
        'would generate an error if you try to load it again...
        'However, if you do wanna 'reload' it, you might want to
        'consider unloading it the same way as u loaded it.
        'Example:
        'Unload picNameOfPic(i)
        'Its simple actually...
    
        If i Then 'i <> 0
           Load picNameOfPic(i)
           picNameOfPic(i).Visible = True
           picNameOfPic(i).Left = picNameOfPic(i - 1).Left + 100 'Move Right 100
           picNameOfPic(i).Top = picNameOfPic(i - 1).Top + 100 'Move Down 100
           'etc....
        End If
      
        'If you want to load an Image into those pics...
        picNameOfPic.Picture = LoadPicture(App.Path & "/imageName.gif")
    Next i
    If you still need any Help you can ask me whatever the problem is...

    Good Luck with this one...
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

  5. #5
    Guest

    How ironic...

    Thanks Man!

    Sorry again for the wrong reply on the other thread...


    Ciao!




  6. #6
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625

    Thumbs up No Problem.

    no, no... its cool.

    No need to appoligize, u did ur best to help.

    And now u just learned something new... thats what programming is all about.
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

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