Results 1 to 5 of 5

Thread: how to separate the decimal portion of the value?

Hybrid View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    6

    how to separate the decimal portion of the value?

    I want to split a value like 150.87 to two different variables a = 150 and b= .87

    i want to separate the decimal portion of the value.

    Please guide me that how can i do it in VB6.

  2. #2
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: how to separate the decimal portion of the value?

    IPart = Fix(Value)
    FPart = Value - IPart

    If you will have negative values, please indicate how you want them treated, for example, -3.5:
    Code:
    IPart | FPart
     -3   | -0.5
      3   |  0.5
     -3   |  0.5
    Last edited by Logophobic; Apr 7th, 2007 at 02:52 PM.

  3. #3

  4. #4
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: how to separate the decimal portion of the value?

    @Martin: That is identical to my code with positive values, but returns undesireable results with negative values.

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: how to separate the decimal portion of the value?

    Quote Originally Posted by Logophobic
    @Martin: That is identical to my code with positive values, but returns undesireable results with negative values.
    You're right.

    MsgBox Abs(x) - Int(Abs(x))

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