+ Reply to Thread
Results 1 to 10 of 10

Error message of CLng

  1. #1
    Registered User
    Join Date
    08-18-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    35

    Error message of CLng

    Hello,

    It may sound really really stupid but I have no idea why CLng does not accept a long string which is a number. I have tried it for the whole night and still have no idea of what's going on

    This is my code:
    Please Login or Register  to view this content.
    And it always come with an error. Thanks very much for helping me.

    Kind Regards,

    Gordon

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Error message of CLng

    the largest value of a long is 2,147,483,647 so your value is a little bit big ;-)
    you need a Double
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Forum Guru tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Error message of CLng

    Excel can't handle numbers larger than 15 digits. You could get that line to work with CDbl instead of CLng, but the resulting number would be 111111111111111000000 because Excel will handle the first 15 digits, and everything after that gets dropped.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Guru tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Error message of CLng

    As an example:
    Please Login or Register  to view this content.
    Run that code and you'll see what I mean

  5. #5
    Registered User
    Join Date
    08-18-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: Error message of CLng

    Many thanks guys!! I thought long is really "long". So I thought it should hold more digits than integer.

    Anyway, many thanks!!!!!



    Good night,

    Gordon

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Error message of CLng

    it does - Long is Long Integer. a regular integer only goes up to 32767

  7. #7
    Registered User
    Join Date
    08-18-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: Error message of CLng

    Yes, I thought the integer usually take more values than variant

  8. #8
    Registered User
    Join Date
    08-18-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: Error message of CLng

    So what does the largest number that a variant hold?

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Error message of CLng

    a variant can hold anything including objects. the largest value it can hold is a double so 1.79769313486232E308

  10. #10
    Registered User
    Join Date
    08-18-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: Error message of CLng

    Thanks JosephP!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1