Results 1 to 8 of 8

Thread: How can one number equal 2 in LEN function???(resolved)

  1. #1

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Resolved How can one number equal 2 in LEN function???(resolved)

    Hello all,

    This is the dumbest thing i've ever seen. I'm trying to see if a number's length is 1 or 2, and doing something from that, but it is messed up.


    Look at my attached screen shots, it says "7" in the LEN function = 2


    What the heck??
    Attached Images Attached Images   
    Last edited by paralinx; Dec 11th, 2005 at 11:13 PM.

  2. #2
    Lively Member MET777's Avatar
    Join Date
    Apr 2005
    Posts
    76

    Re: How can one number equal 2 in LEN function???

    i believe the extra is the space that comes before the number that accomodates the negative sign... but i could be wrong
    --Matt

  3. #3
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: How can one number equal 2 in LEN function???

    Its because what they are dimmed as, a long will return 4 with len. You should wrap it in cstr

    len(cstr(seconds))


  4. #4
    Fanatic Member Jumpercables's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Posts
    592

    Re: How can one number equal 2 in LEN function???

    What are minutes and seconds declared as ? Integers? or strings?

    C# - .NET 1.1 / .NET 2.0

    "Take everything I say with a grain of salt, sometimes I'm right, sometimes I'm wrong but in the end we've both learned something."
    _____________________
    Regular Expressions Library
    Connection String
    API Functions
    Database FAQ & Tutorial

  5. #5

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: How can one number equal 2 in LEN function???

    Quote Originally Posted by Jumpercables
    What are minutes and seconds declared as ? Integers? or strings?
    integers

  6. #6

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: How can one number equal 2 in LEN function???

    Quote Originally Posted by |2eM!x
    Its because what they are dimmed as, a long will return 4 with len. You should wrap it in cstr

    len(cstr(seconds))

    great man, works!

  7. #7
    Fanatic Member Jumpercables's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Posts
    592

    Re: How can one number equal 2 in LEN function???

    Well it might be possible that there is an extra "thing" added onto the minutes/seconds when you are doing a calculation between a String (from text box) and Integer values.

    C# - .NET 1.1 / .NET 2.0

    "Take everything I say with a grain of salt, sometimes I'm right, sometimes I'm wrong but in the end we've both learned something."
    _____________________
    Regular Expressions Library
    Connection String
    API Functions
    Database FAQ & Tutorial

  8. #8
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: How can one number equal 2 in LEN function???

    In this case Len() is converting the number and returning the number of bytes.

    An Iteger/Boolean = 2 Bytes
    A Long/Single = 4 Bytes

    That is what you are seeing.

    The CStr() (as Remix pointed out) is required as the Len() parameter is a String Data Type.

    See also LenB() - (Length of String orvaraible in Bytes).

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