467,161 Members | 873 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,161 developers. It's quick & easy.

Picture Box Slide Show

I have 6 radio buttone and a picture box. I am trying to figure out how to make it so when you click the radio button the image will display in the Picture Box. Any halp would be super.
Nov 5 '06 #1
  • viewed: 12325
2 Replies

try something like:

Expand|Select|Wrap|Line Numbers
  2. Private Sub Option1_Click(Index As Integer)
  3. Picture1.Picture = LoadPicture()
  4. Select Case Index
  5. Case Is = 0: Picture1.Picture = LoadPicture(App.Path & "\Picure1.bmp")
  6. Case Is = 1: Picture1.Picture = LoadPicture(App.Path & "\Picure2.gif")
  7. Case Is = 2: Picture1.Picture = LoadPicture(App.Path & "\Picure3.jpg")
  8. Case Is = 3: Picture1.Picture = LoadPicture(App.Path & "\Picure4.jpg")
  9. Case Is = 4: Picture1.Picture = LoadPicture(App.Path & "\Picure5.bmp")
  10. Case Is = 5: Picture1.Picture = LoadPicture(App.Path & "\Picure6.gif")
  11. End Select
  12. End Sub
note that the size of a picturebox is fixed which is not the case with an image.
simply replace the word Picture1 by Image1 and put an image on your form.
Nov 5 '06 #2
Expert 8TB
try something like:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Option1_Click(Index As Integer)
  2. Picture1.Picture = LoadPicture()
  3. Select Case Index
  4. Case Is = 0: Picture1.Picture = LoadPicture(App.Path & "\Picure1.bmp")
  5. ...
If you want to avoid the delay as each image is loaded, you can load your pictures into six separate Picturebox (or Image) controls once, then just make them visible or not depending on which you want to display. Assuming that these controls are to be in an array, you may find it more convenient to simply create the first one at design time, set the Index property to 0 (zero), then include code something like...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.   Dim I As Long
  3.   For I = 1 To 5
  4.     With Picture1(0)
  5.       Load Picture1(I) ' Create the new picture box.
  6.       Picture1(I).Move .Left, .Top
  7.     End With
  8.   Next
  9. End Sub
Alternatively, you could load the pictures into the controls at design time, so they are stored permanently in your compiled program. Then just use the .Visible property to hide/show them at runtime, or the .ZOrder method to move them in front of or behind each other.

Note: Generally speaking, unless you specifically need properties/methods unique to the picturebox control, you should use the Image control. If it gives you any problems related to size, here's a hint - check out the "Stretch" property.
Nov 5 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Michael Burtenshaw | last post: by
7 posts views Thread by Rudy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.