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?
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.
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?
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.
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
Re: Array for Picture Box or Image...
sorry, use line
Load Picture1(Picture1.Count) for loading new picture box.
Re: Array for Picture Box or Image...
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:
Dim MyPicture() As IPictureDisp
Private Sub Form_Load()
' reserve space for 10 pictures
ReDim MyPicture(9)
' load a picture into the first object
Set MyPicture(0) = LoadPicture("c:\test.jpg")
End Sub
Private Sub Command1_Click()
' you might want to know if there is an image in a picture object
MsgBox "There is a picture in index 0: " & (Not MyPicture(0) Is Nothing)
MsgBox "There is a picture in index 1: " & (Not MyPicture(1) Is Nothing)
' or in a more understandable way:
If MyPicture(1) Is Nothing Then
' make a copy of picture
Set MyPicture(1) = MyPicture(0)
End If
End Sub
Then you can make a scrollbar or a listbox with names to go through the pictures. Set Picture1.Picture = MyPicture(0)
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
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 :)