|
-
November 30th, 2009, 06:00 PM
#1
[RESOLVED] Define a ListBox items text.
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?
Code:
aaa.ItemData(0)="Yes"
aaa.ItemData(1)="No"
Thanks
-
November 30th, 2009, 10:58 PM
#2
Re: Define a ListBox items text.
-
November 30th, 2009, 11:13 PM
#3
Re: Define a ListBox items text.
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
-
December 1st, 2009, 09:26 AM
#4
Re: Define a ListBox items text.
The question is that the list items are already existing.
I want to replace or modifiy them with new values.
How to?
-
December 1st, 2009, 06:23 PM
#5
Re: [RESOLVED] Define a ListBox items text.
How do you think this works?
Code:
msg = List1.ItemData(List1.ListIndex) & " "
msg = msg & List1.List(List1.ListIndex)
You can assign a value, as long as it's the right type
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|