bluesummers
New Member
- Joined
- Sep 25, 2013
- Messages
- 4
Hello all,
I have a small UI where I would like to display an image based on what item is selected in a listbox.
The listbox is multi-coulumn, and the data I want is from the 2nd Column, so I pull the value from the 2nd column and save it in a variable.
The idea is that I have each image pulled in and laid on top of each other. When the ListBox1 is clicked, then it will change the corresponding image's visibility to true, while changing all others to false.
The problem i have is that I cannot think of a way to change the image visibility back to false when a different item is selected from ListBox1.
The code is:
Does anyone have a suggestion or know of a good way to do this?
Thanks a bunch!
I have a small UI where I would like to display an image based on what item is selected in a listbox.
The listbox is multi-coulumn, and the data I want is from the 2nd Column, so I pull the value from the 2nd column and save it in a variable.
The idea is that I have each image pulled in and laid on top of each other. When the ListBox1 is clicked, then it will change the corresponding image's visibility to true, while changing all others to false.
The problem i have is that I cannot think of a way to change the image visibility back to false when a different item is selected from ListBox1.
The code is:
Code:
Private Sub ListBox1_Click()
Dim i As Integer
Dim grabbedListItem As String
' Grabs the selected item from ListBox1's 2nd column and stores it in grabbedListItem
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
grabbedListItem = ListBox1.Column(1, Me.ListBox1.ListIndex)
End If
Next i
' Not static enough. Need images packaged with code, keeping for reference
' imgDisplay.Picture = LoadPicture("C:\TEST\" & grabbedList & ".jpg")
If grabbedListItem = "HCR21" Then
imgHCR21.Visible = True
imgNO_IMAGE.Visible = False
ElseIf grabbedListItem = "HCR22" Then
imgHCR22.Visible = True
ElseIf grabbedListItem = "HA2S3" Then
imgHA2S3.Visible = True
ElseIf grabbedListItem = "HPB11" Then
imgHPB11.Visible = True
ElseIf grabbedListItem = "HPB12" Then
imgHPB12.Visible = True
ElseIf grabbedListItem = "HPB11_BOX" Then
imgHPB11_BOX.Visible = True
Else
imgNO_IMAGE.Visible = True
End If
End Sub
Does anyone have a suggestion or know of a good way to do this?
Thanks a bunch!