Formatnumber

Discussion in 'AutoCAD' started by elefebvre, Jun 10, 2004.

  1. elefebvre

    elefebvre Guest

    I want to have 4.0 appear as 4.0 and not as 4. I tried formatnumber and it does show 4.32 as 4.2, but 4.0 shows as 4. Is there a way to force that it HAS to be 1 digit after the decimal, wheter that is a 0 or not?

    Emmanuel
     
    elefebvre, Jun 10, 2004
    #1
  2. Look at this example

    Sub formatnumber()
    Dim varNumb As Variant
    Dim i As Integer
    varNumb = Array("4.0", "4.32", "4.46", "4.59", "4.89", "4.98")


    For i = LBound(varNumb) To UBound(varNumb)
    MsgBox Format(varNumb(i), "##.0")
    Next
    End Sub


    does show 4.32 as 4.2, but 4.0 shows as 4. Is there a way to force that it
    HAS to be 1 digit after the decimal, wheter that is a 0 or not?
     
    Humberto Guerrero Obando, Jun 10, 2004
    #2
  3. elefebvre

    elefebvre Guest

    doesn't do it for me
     
    elefebvre, Jun 11, 2004
    #3
  4. elefebvre

    Juerg Menzi Guest

    Emanuelle

    'Format' does a 4/5 rounding:
    Format(4, "0.0") -> 4.0
    Format(4.34, "0.0") -> 4.3
    Format(4.35, "0.0") -> 4.4
    Format(0.31, "0.0") -> 0.3
    With two decimals:
    Format(4, "0.00") -> 4.00
    Format(4.34, "0.00") -> 4.34
    Format(4.35, "0.00") -> 4.35
    Format(0.31, "0.00") -> 0.31

    Cheers
    Juerg
     
    Juerg Menzi, Jun 11, 2004
    #4
  5. elefebvre

    elefebvre Guest

    dim KGTOT as Double

    KGTOT = Format(LENTOT * Bar_weight(Val(frmMAIN.DIA)) / 100 / frmMAIN.units_BBS, "0.0")

    still returns 4 in case the result of the formula is 4.03 for instance.

    i don't know what i'm doing wrong
     
    elefebvre, Jun 11, 2004
    #5
  6. elefebvre

    elefebvre Guest

    sorry for bothering. as i was sending the message, a 'light' went on. I set the KGTOT as string and of course it workd now!!

    thanks for leading me graciously to the solution :)
     
    elefebvre, Jun 11, 2004
    #6
  7. elefebvre

    Juerg Menzi Guest

    Glad to help you...:cool:

    Cheers
    Juerg
     
    Juerg Menzi, Jun 11, 2004
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.
Loading...