Hello, I am building a listbox from another list, but the following code doesn't work.
ListBox2. AddItem ListBox1. Value
Anyone could tell me why? Thanks in advance!
Leon
Hello, I am building a listbox from another list, but the following code doesn't work.
ListBox2. AddItem ListBox1. Value
Anyone could tell me why? Thanks in advance!
Leon
Hello Leon,
If the user has not selected an item in ListBox1, it's value is Null. Attempting to add this to ListBox2 is what causes an error. The AddItem method only accepts strings.
If you want ListBox2 to be updated whenever an item in ListBox1 is selected, you need to place your code in the Click event for ListBox1.
Code Example:
Private Sub ListBox1_Click()
ListBox2.AddItem ListBox1.Value
End Sub
Sincerely,
Leith Ross
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks