-
April 5th, 2012, 05:13 AM
#1
Combo.ItemData maximum value
Hi all
First of all, sorry for my poor english writing.
My question is:
Why I can NOT set the value "11001000000" to one of combo items as its ItemData value?
I mean:
With Recordset1
.Sort = "ID Asc"
.MoveFirst
While Not .EOF
sItem = .Fields("Code") & " - " & .Fields("Name")
Combo1.AddItem (sItem)
Combo1.ItemData(Combo1.NewIndex) = .Fields("ID")
.MoveNext
Wend
End With
Now, VB 6.0 compiler shows me "Overflow 6" error message for the line "Combo1.ItemData(Combo1.NewIndex) = .Fields("ID") " when .Fields("ID") has the value equal to 11001000000.
How can I solve this problem?
-
April 5th, 2012, 05:47 AM
#2
Re: Combo.ItemData maximum value
If the value in ID is meant to be a decimal numeric, it overflows the ItemData() capacity, which, as far as I know, is limited to Long, that is +/- 2^31
The value of 11001000000 can be represented by a Double.
The first idea come to mind is, you have to maintain a (dynamic) array of Doubles which holds the ID.
-
April 6th, 2012, 12:31 PM
#3
Re: Combo.ItemData maximum value
Thank you WoF for your attention,
But how can I use the dynamic array that you said with the combo that has been filled by a recordset?
-
April 6th, 2012, 12:44 PM
#4
Re: Combo.ItemData maximum value
What's the data type in the DB? That's what you'd change.
-
April 7th, 2012, 12:04 AM
#5
Re: Combo.ItemData maximum value
@dglienna:
Well, as I mentioned in my first post, the recordset which my combo will be filled by has 3 column: ID (bigint) , Name (varchar(50)) and code (char(9)).
The combo will be filled by it in order that ID will be itemData of every item and I use Code+ --+Name as displayValue
but it seems that the value
11001000000
can not be set as itemdata
how can I solve this problem?
thank you
-
April 7th, 2012, 12:28 PM
#6
Re: Combo.ItemData maximum value
How can it fit in 9 characters?
Looks like 11 to me
-
April 7th, 2012, 10:53 PM
#7
Re: Combo.ItemData maximum value
@ dglienna:
11001000000 is not code. It's ID which will be used as itemdata of every item in combo.
-
April 8th, 2012, 09:59 AM
#8
Re: Combo.ItemData maximum value
Hi odiseh
property ItemData is datatype Long, the value that you want to set it's not posible
11001000000 is out range to Long.
so I time ago used work :
Code:
With Recordset1
.Sort = "ID Asc"
.MoveFirst
While Not .EOF
sItem = .Fields("Code") & " - " & .Fields("Name")
Combo1.AddItem (sItem)
if combo1.tag="" then
combo1.tag=cstr( .Fields("ID"))
else
combo1.tag=combo1.tag & "," & cstr( .Fields("ID"))
end if
.MoveNext
Wend
End With
and you could get to get the value as :
Code:
dim v() as string
v = Split(combo1.tag, ",")
Debug.Print v(combo1.ListIndex)
I hope this is useful
-
April 9th, 2012, 05:44 AM
#9
Re: Combo.ItemData maximum value
@hensa22:
hi
Thanks alot for your attention. Your solution seems to be correct and is a nice way. I'll try it in my project. Thank you very much
Last edited by odiseh; April 9th, 2012 at 05:46 AM.
-
April 10th, 2012, 08:52 AM
#10
Re: Combo.ItemData maximum value
Nice idea, yes. Only watch that you don't use the .Sort option in the Combobox, because this will then mix up the relation item<->ID
Tags for this Thread
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
|