|
-
Jun 22nd, 2000, 05:11 PM
#1
Thread Starter
Frenzied Member
Has anyone ever tried using number as a listitem key?
You can't do it!
Even if the number is a string it complains.
Code:
Private Sub Command1_Click()
Dim itmx As ListItem
Dim strKey As String
strKey = CStr(22222)
Set itmx = ListView1.ListItems.Add(, strKey, "Item 1")
End Sub
Is there a way around this?
-
Jun 22nd, 2000, 05:29 PM
#2
Fanatic Member
Weird, it seems to work with very large numbers. i tried "10000000000" and it worked.
Iain, thats with an i by the way!
-
Jun 22nd, 2000, 05:58 PM
#3
I thinhk you sould add a special text character at the beginning strkey.
I always use "key" : strkey = "key" & cstr(22222).
-
Jun 22nd, 2000, 06:02 PM
#4
Thread Starter
Frenzied Member
Well that's one way npminh but it's messy and I shouldn't have to because cstr(22222)is a string and the key need to be a string.
-
Jun 22nd, 2000, 06:04 PM
#5
-
Jun 22nd, 2000, 06:23 PM
#6
it is because you can access the items by Index or by Key.
So it would never know if you where accessing a key or an index.
-
Jun 22nd, 2000, 06:37 PM
#7
Fanatic Member
Thats just plain dumb.
If you pass it a string, then it should look for the key.
The index is a number, so if you pass it a number, it should look for the index.
Bloody VB.
Iain, thats with an i by the way!
-
Jun 22nd, 2000, 07:24 PM
#8
Well thats the way variants work.
Thats why variants suck, but i guess its is the only way to accept strings/numbers.
-
Jun 22nd, 2000, 10:05 PM
#9
Hyperactive Member
The same thing happens with the treeview. To get around it I used npminh's method.
-
Jun 23rd, 2000, 12:47 AM
#10
PowerPoster
Extra Alphabet
How about just add an extra alphabet infront of the supplied key?
Code:
Private Sub Command1_Click()
Dim itmx As ListItem
Dim strKey As String
strKey = "k" & CStr(22222)
Set itmx = ListView1.ListItems.Add(, strKey, "Item 1")
End Sub
I always did that, instead of using integer or long as my key value.
Hope this will work for you.
Cheers!
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
|