![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| [SOLVED] need help in showing pictures in a visual basic program? the thing that im doing is an ipod, now in the photos form i want the photos to appear one by one when the user clicks on the command button that has an arrow to the right (i dont want it to be a slide show, i want the picture to change only when the user clicks on the command button) plz state the whole code if you can, and try to make it easy plz.... and thnx by the way ;-) |
| |
| |||
| assuming that you're using VB6: - put all the pictures in a sub-folder of the folder where your program is installed, let's say this pictures subfolder is called "photos" -------------------------------- - put a FileListBox (named File1) object on your form (it would be better to use the FileSystemObject object but I won't get into that, as it's a little more complicated), so, on the form's Load Event write this: Dim picturesFolder As String 'assuming that all your pictures are JPG 'if you have different types of pictures don't use the next line but make sure to put only pictures in that folder File1.Pattern = "*.jpg" 'set the pictures folder picturesFolder = App.Path & "\photos\" 'if the pictures folder exists and has files in it If Dir(picturesFolder) <> "" Then File1.Path = picturesFolder Else MsgBox "can't find pictures in " & picturesFolder End If 'hide the file list, as we are using it only to get the file names File1.Visible = False 'set the current index of the displayed file to 0 (the first file in the list) crtIdx = 0 'display the first picture If (File1.ListCount > 0) Then Picture1.Picture = LoadPicture(File1.Path & "\" & File1.List(crtIdx)) end if -------- - put a pictureBox object on your form (named Picture1) -------- - make a private variable for the form to hold the current index of the displayed file (select General, then Declarations from the code window) and write private crtIdx as Integer -------- - on the button that you use to display the next picture (on the OnClick event) write this ' go to the next picture If crtIdx < File1.ListCount - 1 Then crtIdx = crtIdx + 1 Else crtIdx = 0 End If 'display that picture If (File1.ListCount > 0) Then Picture1.Picture = LoadPicture(File1.Path & "\" & File1.List(crtIdx)) end if if you're using VB .NET email me, I'll give you an example for that as well ![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |