Hello

Can I get 20 pictures opened from visual basics, for example I have a list box with the name of the pictures, unfortunately I cannot open none of them, can someone please send me some code, all I want to do is have a right and left arrow, and each time a user pressed right it will display the next picture, can anyone please help.

thanks for looking

as i said i will have a list box, all i want to do is one the user click on the left and right arrow, it should disply the next picture, is there a way of me doing that, if so can you please show me the code, thanks again

What is the type of the picture ? If it is something common like bmp, jpg etc, use a image or picture box control to display it.

Image1.Picture = Loadpicture(Full_Path_Of_The Picture_File)

If it is something that VB does not support, do you want to open the picture through an external program ? In that case, use the ShellExecute API function

Right. Something else you'll need to take into consideration is the size of the image. If you set it to be auto-size (the picture or image control) then it will change depending on the size of the picture.... if you don't, it will chop off the image so you can't see it all. Now, you could use an image control instead of a picturebox control, and set it's stretch property to true, which will shrink the image (or whatever) to the size of the image control, BUT it doesn't render the image with any kind of decent quality. When I wrote a picture viewer, I made a seperate form that was used as the viewer pane, and resized the entire form to a given ratio based on the size of the picturebox, so that way it didn't seem too flawed. Good luck with your project.

Hello the picture will only be the standard type Jpg type, all I want is any code just to view 20 pictures, am not to concern about the size, I could probably do that. All I really need is the code to view the pictures, preferably with two arrows for example if the user point left arrow it will go to picture 20 and if her presses the right arrow it will go to picture 1.

I think I could have a list box with the picture in, is that the way you would do it, can you please send me an attachment, or your code if you have done it, and I need something similar

Please help me, am really confused
Thanks

I don't really have a code, but it's quite simple. You need a image or picturebox control to display the picture, u can't really do that in a list box.

Assuming there are 20 pictures, take an array for the filenames in the General Declarations section.

Dim strFiles(20) as string

Now put in the filenames in the array. Depending on ur project u can use a full path or a relative path.

strFiles(1) = PATH_OF_FILE1
strFiles(2) = PATH_OF_FILE2
....
strFiles(20) = PATH_OF_FILE20

Also declare a variable in the General Declarations section. This variable can be used as a counter.

Dim mCtr as integer

If there are 2 command buttons, cmdLeft and cmdRight, then in their click section write

Private Sub cmdLeft_Click()
if mCtr > 1 then
   mCtr = mCtr - 1
end if
Picture1.Picture = LoadPicture(strFiles(mCtr))
End Sub

assuming Picture1 to be Picturebox that will display the picture

In the same way write for cmdRight

Private Sub cmdRight_Click()
if mCtr < 20 then
   mCtr = mCtr + 1
end if
Picture1.Picture = LoadPicture(strFiles(mCtr))
End Sub

and ur pictures will be displayed. Use the 2 buttons to browse through the pictures

Thanks for your code, however I still can’t make it work, the first picture does not even come up, it does execute but nothing happened, will it be possible for you to send an attachment in vb, so I can see how you make it work, you can put in any 2 or more pictures, once I know how it works I am sure I can make mine work too, don’t be tooo concern with the code, please help me make it work

Most of the code I have already given. To see the first picture when the form loads, write in the form -> load section

strFiles(1) = PATH_OF_FILE1
.....
strFiles(20) = PATH_OF_FILE20

Image1.Picture = LoadPicture(strFiles(1))

If you are getting an error, please specify the error number & description.

Comatose, sorry about last post. Remembered this time :o

the syntax is not correct but this is how i would approch it

global piccnt as interger' in a modual

onform load 'set the 1st picture
piccnt = 0
pitcure1.picture = filepath & listbox.listindex(piccnt)

sub click arrow button right
piccnt = piccnt + 1
if piccnt >then listcount.indexcount then piccnt = 0
pitcure1.picture = filepath & listbox.listindex(piccnt)

end sub


sub click arrow button left
piccnt = piccnt - 1
if piccnt <then listcount.indexcount then piccnt = listindex.count.lastin the index
pitcure1.picture = filepath & listbox.listindex(piccnt)

end sub

This article has been dead for over six months. Start a new discussion instead.