Hi,
Suppose I have a listbox aaa which has two items.
How to define the text for each item?
My code is incorrect but not sure why?
ThanksCode:aaa.ItemData(0)="Yes"
aaa.ItemData(1)="No"
Printable View
Hi,
Suppose I have a listbox aaa which has two items.
How to define the text for each item?
My code is incorrect but not sure why?
ThanksCode:aaa.ItemData(0)="Yes"
aaa.ItemData(1)="No"
Try
aaa.additem "Yes"
Here's something I did a while back, to illustrate the ListIndex property as well
Code:Option Explicit
Private Sub Combo1_Click()
Dim msg As String
' MsgBox Combo1.Text
msg = Combo1.ItemData(Combo1.ListIndex) & " "
msg = msg & Combo1.List(Combo1.ListIndex)
MsgBox msg
End Sub
Private Sub Form_Load()
' Could also use ' List1.ItemData(0) = 5
List1.AddItem "David G"
List1.ItemData(List1.NewIndex) = 42001 ' New Index
List1.AddItem "Greg G"
List1.ItemData(List1.NewIndex) = 42000 ' New Index
Combo1.AddItem "David G"
Combo1.ItemData(Combo1.NewIndex) = 42001 ' New Index
Combo1.AddItem "Greg G"
Combo1.ItemData(Combo1.NewIndex) = 42000 ' New Index
End Sub
Private Sub List1_Click()
' Append Name to ItemData
Dim msg As String
' msgbox list1.text
msg = List1.ItemData(List1.ListIndex) & " "
msg = msg & List1.List(List1.ListIndex)
MsgBox msg
End Sub
The question is that the list items are already existing.Quote:
Try
aaa.additem "Yes"
I want to replace or modifiy them with new values.
How to?
How do you think this works?
You can assign a value, as long as it's the right typeCode:msg = List1.ItemData(List1.ListIndex) & " "
msg = msg & List1.List(List1.ListIndex)