Results 1 to 5 of 5

Thread: Long to Integer

  1. #1

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    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).]

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    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


  3. #3
    Junior Member
    Join Date
    Jun 1999
    Posts
    22

    Post

    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

  4. #4

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    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

  5. #5
    Junior Member
    Join Date
    Jun 1999
    Posts
    22

    Post

    As you said I tried value=cint(vlong), It gives the error message "Overflow".

    Latha

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width