Results 1 to 10 of 10

Thread: Array for Picture Box or Image...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Posts
    69

    Array for Picture Box or Image...

    I already have some pictures (jpeg) of student. i want to show them in thumbnail mode with Picture Box or Image...but according filter-condition, i have to make the number of picture box or image is variable. Can i set a picture box or image as an array?

  2. #2
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    Re: Array for Picture Box or Image...

    you can use control array of pircture box.
    use function "Load controlname" for loading a control array element on run time.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Posts
    69

    Unhappy Re: Array for Picture Box or Image...

    sorry...i can not get what you mean.

    did i have to declare picture box array like : dim vPICT(1 to 100) as PictureBox or what...?

    can u give me more detail explanation?

  4. #4
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    Re: Array for Picture Box or Image...

    you need not to define it.
    At the design time just load one picture box with index 0.
    then at run time each time when you want to load new picture , use function
    "Load picture1(picture1.count-1" to load a new control.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Posts
    69

    Re: Array for Picture Box or Image...

    won't work....

    my simple code:

    Dim I as Integer
    For I = 1 to 10
    Load Picture1(Picture1.Count + 1)
    Next I

    'Then I try to fill with blank
    For I = 1 to 10
    Picture1(I).Picture = LoadPicture("") ...this line created an error
    Next I

    and the vb said: Control array element "1" doesn't exist

  6. #6
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    Re: Array for Picture Box or Image...

    sorry, use line
    Load Picture1(Picture1.Count) for loading new picture box.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Posts
    69

    Re: Array for Picture Box or Image...

    thanx...it's work

  8. #8
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Array for Picture Box or Image...

    Although loading over 20 or so controls for pictures is a waste; you can also store images into picture objects that don't have a control attached to them, thus saving memory and resources.

    VB Code:
    1. Dim MyPicture() As IPictureDisp
    2.  
    3. Private Sub Form_Load()
    4.     ' reserve space for 10 pictures
    5.     ReDim MyPicture(9)
    6.     ' load a picture into the first object
    7.     Set MyPicture(0) = LoadPicture("c:\test.jpg")
    8. End Sub
    9. Private Sub Command1_Click()
    10.     ' you might want to know if there is an image in a picture object
    11.     MsgBox "There is a picture in index 0: " & (Not MyPicture(0) Is Nothing)
    12.     MsgBox "There is a picture in index 1: " & (Not MyPicture(1) Is Nothing)
    13.     ' or in a more understandable way:
    14.     If MyPicture(1) Is Nothing Then
    15.         ' make a copy of picture
    16.         Set MyPicture(1) = MyPicture(0)
    17.     End If
    18. End Sub

    Then you can make a scrollbar or a listbox with names to go through the pictures. Set Picture1.Picture = MyPicture(0)

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Posts
    69

    Re: Array for Picture Box or Image...

    you're right too merri...and thanx alot.
    but while i'm using thrid-party ocx from Tidestone (FormulaOne), all picture has to put in a different picture box for print purpose...about the memory...don't worry. the picture cannot be more then 200 with less than 20Kb size each

    but anyway...you give me a new idea and nice code....thanx again

  10. #10
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Array for Picture Box or Image...

    Note that loading the JPEG files into memory will change them to native BMP images and they'll consume much more memory

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