Sure thing! The project contains 2 forms (frmImage, frmMain). frmImage has a picturebox (picImage) and frmMain has 2 option buttons in an array (optChoices).
No code in frmImage, copy and paste this in frmMain:
- ' Used to preload and hold our images
-
Private spicA As StdPicture
-
Private spicB As StdPicture
-
-
Private Sub Form_Load()
-
' Load the images for use
-
Set spicA = LoadPicture(App.Path & "\a.bmp")
-
Set spicB = LoadPicture(App.Path & "\b.bmp")
-
' Let's show the Picture form and make it our child
-
frmImage.Show vbModeless, Me
-
End Sub
-
-
Private Sub Form_Unload(Cancel As Integer)
-
' Release/Clear our loaded images
-
Set spicB = Nothing
-
Set spicA = Nothing
-
' Finally, unload our Picture form
-
Unload frmImage
-
End Sub
-
-
Private Sub optChoices_Click(Index As Integer)
-
' Select case for easy expandability
-
Select Case Index
-
Case 0 ' A
-
Set frmImage.picImage.Picture = spicA
-
Case 1 ' B
-
Set frmImage.picImage.Picture = spicB
-
End Select
-
End Sub
As you can see, it looks for a.bmp and b.bmp in the same folder as the program resides. These can be any image (adjust your picturebox on frmImage if you wish).
I really hope this clarifies things for you, jcb! Feel free to pick my brain some more. :)
--EDIT--
By the way, this will NOT load a default image, as no option buttons are selected. If you want to set a default, just add this to your Form_Load:
- optChoices(0).Value = True
Changing the index to something other than 0 will select whichever option button you wish to have selected on load. Also, changing the .Value will also initiate the "Click" event, where we change the images. Just make sure you put the above code AFTER we load the images.(Set spicA = LoadPicure)