Results 1 to 8 of 8

Thread: Selecting all numbers after decimal point

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Posts
    82

    Selecting all numbers after decimal point

    how would I do this?

    Shak

  2. #2
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Catalonia
    Posts
    397
    VB Code:
    1. Number = 45.235
    2. strnumber = CStr(Number)
    3. pos = InStr(strnumber, ".")
    4. decimals = Right(strnumber, Len(strnumber) - pos)

    If your PC has , as decimal separator (european settings) then put "," instead "." inside InStr
    Josep Mª

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Posts
    82
    thanks

  4. #4
    Addicted Member
    Join Date
    Aug 2001
    Posts
    158
    or y=x-int(x)

  5. #5
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    Originally posted by Everso
    or y=x-int(x)
    RobShakir, this is probably a better option because it will be faster becase there are no strings involved. however there are few situation where it will matter. It is only important in loops. Just thought i'd let you know.
    You just proved that sig advertisements work.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Posts
    82
    thanks

    I have it now

    Shak

  7. #7
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Catalonia
    Posts
    397
    Originally posted by Everso
    or y=x-int(x)
    Both codes are for a different purpose

    Using Int
    x=43.235
    y=0.235

    Using strings
    x=43.235
    y=235

    Only one code works depending on what is required
    Josep Mª

  8. #8
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    Originally posted by joijo


    Both codes are for a different purpose

    Using Int
    x=43.235
    y=0.235

    Using strings
    x=43.235
    y=235

    Only one code works depending on what is required
    good point...
    You just proved that sig advertisements work.

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