PDA

Click to See Complete Forum and Search --> : Long to Integer


MartinLiss
Dec 10th, 1999, 12:04 AM
Are you trying to get around the error? You can't if the long is less than -32,768 or greater than 32,767. By the way, look up CInt in help and you will find a discussion of various conversions.

------------------
Marty

[This message has been edited by MartinLiss (edited 12-10-1999).]

Serge
Dec 10th, 1999, 12:08 AM
It happens because you're trying to convert the number that is already bigger then Integer's maximum value (32,767), that's why generates an error (6 - Overflow).

------------------

Serge

Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)

swarnalatha
Dec 10th, 1999, 11:15 AM
All,
How shall I do the datatype conversion from Long to Integer.
I did the following.

Dim vlong as long
dim value as integer

value=int(vlong). But I am getting the result that I expect.
Thanks.
Latha

MartinLiss
Dec 10th, 1999, 11:43 AM
Well, Long is already an integer type, as a matter of fact "Long" is just convenient shorthand for "Long Integer". The difference between Long and Integer is the the former can store larger numbers. If you do value = cInt(vlong) or just value = vlong, VB will do the "conversion" for you, but you will get an error if vlong is too large.

------------------
Marty

swarnalatha
Dec 10th, 1999, 11:57 AM
As you said I tried value=cint(vlong), It gives the error message "Overflow".

Latha