Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overflow : 'Cint' 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi, I have this array of numbers, but they were stored as strings, I want to convert them to integers, so I used the following code

for i = 0 to UBound(arrTest)
arrTest(i) = CInt(arrTest(i))
next

but it's giving me the error msg Overflow : 'Cint'
How can I fix it?
 
I would make sure that the values you are trying to convert to Integer fall within the interger values accepted. Maybe one of the values is to large to be converted to Interger.

You might try CLng or if that is not big enough you could go with Cdbl

The following is a list of the types and what values they can store.

CByte Byte 0 to 255.

CInt Integer -32,768 to 32,767.

CLng Long -2,147,483,648 to 2,147,483,647.

CSng Single -3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values.

CDbl Double -1.79769313486232E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values.

CCur Currency -922,337,203,685,477.5808 to 922,337,203,685,477.5807.


Hope this helps.......
 
Hi! i changed it to Cdbl, now it works
but what i dont undrstand it, in the list of arrays, i am 100% every entry contains a 5 digit number, and 5 digits ONLY
how come cint won't work?
 
it could be only five digits but if that 5 digit is say 32768 then you will get the overflow error since the Integer can only store a value as high as 32767. If you know that you only have 5 digits you might go with the CLng since it can store a value as high as 2147483647 and it does not have quite as big a footprint as CDbl.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top