8. Write a VB program to take one list box, it contains name of picture file. If you click on particular picture file name then corresponding picture should be display onto the picture box.


Private Sub Form_Load()
List1.Clear
List1.AddItem “Sunset”
List1.AddItem “Water Lilies”
List1.AddItem “Winter”
List1.AddItem “Blue hills”
End Sub

Private Sub List1_Click()
For i = 0 To List1.ListCount – 1
If List1.ListIndex = 0 Then
Label2.Caption = “Sunset”
Picture1.Picture = LoadPicture(“C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Sunset.jpg”)
ElseIf List1.ListIndex = 1 Then
Label2.Caption = “Water Lilies”
Picture1.Picture = LoadPicture(“C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water lilies.jpg”)
ElseIf List1.ListIndex = 2 Then
Label2.Caption = “Winter”
Picture1.Picture = LoadPicture(“C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg”)
Else
Label2.Caption = “Blue hills”
Picture1.Picture = LoadPicture(“C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Blue hills.jpg”)
End If
Next
End Sub

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s