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.
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.
@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
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)
Bookmarks