+ Reply to Thread
Results 1 to 4 of 4

Equation Miscaculation

  1. #1
    Forum Contributor
    Join Date
    03-09-2004
    Posts
    140

    Equation Miscaculation

    Hi there
    When I put this formating to the value of TextBoxs,

    Please Login or Register  to view this content.
    Then the result of this line is always 1 or not correct
    Please Login or Register  to view this content.
    However, when i cancel the formating then the equation gives correct result but with no comma nor period.....which are realy needed

    How can get the correct result out of equation ?

    The whole code:
    Please Login or Register  to view this content.
    Last edited by helmekki; 11-21-2005 at 11:24 AM.
    Yours
    hesham Almakki
    http://www.almakki.com.ly/

  2. #2
    Tom Ogilvy
    Guest

    Re: Equation Miscaculation

    from the immediate window:
    ? val("10,000")
    10
    ? cdbl("10,000")
    10000

    so you might want to use cdbl instead of Val.

    --
    Regards,
    Tom Ogilvy

    "helmekki" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi there
    > When I put this formating to the value of TextBoxs,
    >
    >
    > Code:
    > --------------------
    > Gtot.Value = Format(Gtot.Value, "#,##0.000")
    > tot.Value = Format(tot.Value, "#,##0.000")
    > bal.Value = Format(bal.Value, "#,##0.000")
    > --------------------
    >
    >
    > Then the result of this line is always 1 or not correct
    >
    > Code:
    > --------------------
    > bal.Value = val(Gtot.Value) - val(tot.Value)
    > --------------------
    >
    >
    > How can get the correct result out of equation ?
    >
    >
    > --
    > helmekki
    >
    >
    > ------------------------------------------------------------------------
    > helmekki's Profile:

    http://www.excelforum.com/member.php...fo&userid=6939
    > View this thread: http://www.excelforum.com/showthread...hreadid=486844
    >




  3. #3
    Bob Phillips
    Guest

    Re: Equation Miscaculation

    You don't say where these objects are, but I tried textboxes on a userform
    and it worked okay. What are the objects?

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "helmekki" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi there
    > When I put this formating to the value of TextBoxs,
    >
    >
    > Code:
    > --------------------
    > Gtot.Value = Format(Gtot.Value, "#,##0.000")
    > tot.Value = Format(tot.Value, "#,##0.000")
    > bal.Value = Format(bal.Value, "#,##0.000")
    > --------------------
    >
    >
    > Then the result of this line is always 1 or not correct
    >
    > Code:
    > --------------------
    > bal.Value = val(Gtot.Value) - val(tot.Value)
    > --------------------
    >
    >
    > How can get the correct result out of equation ?
    >
    >
    > --
    > helmekki
    >
    >
    > ------------------------------------------------------------------------
    > helmekki's Profile:

    http://www.excelforum.com/member.php...fo&userid=6939
    > View this thread: http://www.excelforum.com/showthread...hreadid=486844
    >




  4. #4
    Forum Contributor
    Join Date
    03-09-2004
    Posts
    140
    Thank u very much indeed..........

    cdbl solved the problem and i now understand the difference between

    val(10000) with format TextBox1.Value = Format(TextBox1.Value, "#,##0.000")
    appears as 10

    and

    CDbl(10000) with format TextBox1.Value = Format(TextBox1.Value, "#,##0.000")
    appears as 10,000.000

+ 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