|
This is a program that allows
the user to select an item from a combo box and display its
image in an image box. The program is suitable to create an
education game for the children.
In this example, I create a
simple astronomical program to allow the user to view all
the nine planets of our solar system. In this program, I
insert an a combo box and an image box. Planets are added to
the combo box using the AddItem method at start up. In order
to display the image, I use the Select Case .........End
Select statement and the LoadPicture method to load the
picture into the image box. You have to modify this program
so that it follow the correct path in your computer. You can
always change the program to something else like list of
animals, list of plants and etc. |
Private Sub Combo1_Click()
Select Case Combo1.ListIndex
Case 0
Image1.Picture = LoadPicture("D:\Liew Folder\VB
Tutorial\Images\mercury.jpg")
Case 1
Image1.Picture = LoadPicture("D:\Liew Folder\VB
Tutorial\Images\venusmar.jpg")
Case 2
Image1.Picture = LoadPicture("D:\Liew Folder\VB
Tutorial\Images\earthafr.jpg")
Case 3
Image1.Picture = LoadPicture("D:\Liew Folder\VB
Tutorial\Images\Mars.jpg")
Case 4
Image1.Picture = LoadPicture("D:\Liew Folder\VB
Tutorial\Images\Jupiter500.jpg")
Case 5
Image1.Picture = LoadPicture("D:\Liew Folder\VB
Tutorial\Images\Saturn.jpg")
Case 6
Image1.Picture = LoadPicture("D:\Liew Folder\VB
Tutorial\Images\Uranus.jpg")
Case 7
Image1.Picture = LoadPicture("D:\Liew Folder\VB
Tutorial\Images\Neptune.jpg")
Case 8
Image1.Picture = LoadPicture("D:\Liew Folder\VB
Tutorial\Images\plutobig.jpg")
End Select
End Sub
Private Sub Form_Load()
Combo1.Text = "Select Picture"
Combo1.AddItem "Mercury"
Combo1.AddItem "Venus"
Combo1.AddItem "Earth"
Combo1.AddItem "Mars"
Combo1.AddItem "Jupiter"
Combo1.AddItem "Saturn"
Combo1.AddItem "Uranus"
Combo1.AddItem "Neptune"
Combo1.AddItem "Pluto"
End Sub
|