In this posting I will write a Sample of Simple VB6 program to display images in a directory of your computer. To display image in VB6 programming you can use LoadPicture statement. The format of statement is:
LoadPicture (Path\FileName)
For example:
LoadPicture ("Image01.jpg") -> display image named Image01.jpg in the current folder (the folder of image and the program is the same)
LoadPicture ("d:\MyPicture\Image02.bmp") -> display image named Image02.bmp that stored in folder MyPicture in drive d:
To make a VB6 program application like the above illustration you can follow below VB6 Programming tips.
In this case assumed that you have some images file (with extention .jpg or .bmp) that stored in directory D:\MyPicture.
Now you have to create a screen design like below image:
To create the screen design, please follow below steps:
Ok, program interface already done. Now the time to write code statements to functionate the controls, so the program can work. Dir1.Path = Drive1.Drive
File1.Path = Dir1.Path File1.Path = Dir1.Path
On Error GoTo ErrHandle
Image1.Picture = LoadPicture(File1.Path & "/" & File1.FileName)
Exit Sub
ErrHandle:
MsgBox "Invalid Image display"
Resume Next
So your Program coding will look like below listing:Private Sub Dir1_Change()
File1.Path = Dir1.Path
End SubPrivate Sub Drive1_Change()
Dir1.Path = Drive1.Drive
File1.Path = Dir1.Path
End SubPrivate Sub File1_Click()
On Error GoTo ErrHandle
Image1.Picture = LoadPicture(File1.Path & "/" & File1.FileName)
Exit Sub
ErrHandle:
MsgBox "Invalid Image display"
Resume Next
End Sub
Now the time to test your program, follow below tips:
Your program should like the illustration on the top of this posting, however the image you display depend on the image you have and select.
How to Display Images in a Folder with VB6 Program ?
Subscribe to:
Post Comments (Atom)
Labels
- Stop Dreaming Start Action (1)
- Table of Contents (1)
- VB6 Programming (36)
- VB6 Sample Program (16)
1 comments:
Thanks for post. It’s really imformative stuff.
I really like to read.Hope to learn a lot and have a nice experience here! my best regards guys!
--
rockstarbabu
--
SEO----SEO
Post a Comment