By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,986 Members | 1,537 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,986 IT Pros & Developers. It's quick & easy.

Picture Box Slide Show

P: 1
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
Share this Question
Share on Google+
2 Replies


100+
P: 267
hi

try something like:

Expand|Select|Wrap|Line Numbers
  1.  
  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
  13.  
  14.  
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 5K+
P: 8,434
hi
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.