mbw
October 5th, 2001, 02:04 PM
Ok, I know why I'm getting this error but can't figure out how to fix it.
I'm trying to create a string of index values based on what is selected in a listbox. The listbox is populated with two values: The itemdata and an index value tied to the item data. For example, the user sees itemdata such as 'Harry' in the listbox which is tied to an index value corresponding to let's say Harry's customer id. I want to be able to create a string of these customer id values hidden within the listbox's index. I also need to create a string of the itemdata value's as well.Here's a short sample of my code that tries to pull out a string of itemdata and index data:
Dim index as string
Dim itemdata as string
Dim i as Integer
Dim first as Boolean
first = true
for i = 0 to (list1.ListCount - 1)
If (list1.Selected(i)) then
If (first) then
itemdata = "(" & list1.ItemData(i)
index = "(" & list1.ItemData(list1.ListIndex)(i)
first = false
else
itemdata = itemdata & "," & list1.Itemdata(i)
index = index & "," & list1.ItemData(list1.ListIndex)(i)
End If
End If
next i
itemdata = itemdata & ")"
index = index & ")"
This code is tied to a command button. If item values 'Harry', 'Mary', 'Bob' are selected the output should be a string of customerids like (1,4,6) for example. But everytime I run it I get a 'type mismatch' error due to trying to create the string of index values. I've never tried creating a string of values based on a listbox's index, only it's itemdata. Any help would be great! Thanks.
I'm trying to create a string of index values based on what is selected in a listbox. The listbox is populated with two values: The itemdata and an index value tied to the item data. For example, the user sees itemdata such as 'Harry' in the listbox which is tied to an index value corresponding to let's say Harry's customer id. I want to be able to create a string of these customer id values hidden within the listbox's index. I also need to create a string of the itemdata value's as well.Here's a short sample of my code that tries to pull out a string of itemdata and index data:
Dim index as string
Dim itemdata as string
Dim i as Integer
Dim first as Boolean
first = true
for i = 0 to (list1.ListCount - 1)
If (list1.Selected(i)) then
If (first) then
itemdata = "(" & list1.ItemData(i)
index = "(" & list1.ItemData(list1.ListIndex)(i)
first = false
else
itemdata = itemdata & "," & list1.Itemdata(i)
index = index & "," & list1.ItemData(list1.ListIndex)(i)
End If
End If
next i
itemdata = itemdata & ")"
index = index & ")"
This code is tied to a command button. If item values 'Harry', 'Mary', 'Bob' are selected the output should be a string of customerids like (1,4,6) for example. But everytime I run it I get a 'type mismatch' error due to trying to create the string of index values. I've never tried creating a string of values based on a listbox's index, only it's itemdata. Any help would be great! Thanks.