General String Number Formatting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • str1ker
    New Member
    • Jun 2006
    • 23

    General String Number Formatting

    Hi again. :)

    Does anyone know of a simple way to turn integers into formatted strings?

    E.G.
    1000 = 1,000


    And is there any other simple way of cutting off decimals to a certain number of places? It cannot be rounding up or down, because it effects broken units such as inches, feet, etc. when they are modified for a list.

    E.G.
    8.79823 = 8.79
    11.9999 = 11.99

    The last conversion would nomally round up to 12, but I don't want that to happen.

    Thank you. :rolleyes:
  • Hemant Pathak
    Recognized Expert New Member
    • Jul 2006
    • 92

    #2
    u can try to use this code i have checked it working........ .

    Dim n1
    n1 = "8.79823"
    'n1 = 875
    n1 = Mid$(n1, 1, IIf(InStr(1, n1, ".") <> 0, InStr(1, n1, ".") + 2, Len(n1)))
    MsgBox n1






    enjoy.......... .............

    Comment

    • str1ker
      New Member
      • Jun 2006
      • 23

      #3
      Thank u!

      Do u also know the thousand seperator formmating?

      1000 = 1,000

      Comment

      • sashi
        Recognized Expert Top Contributor
        • Jun 2006
        • 1749

        #4
        Hi there,

        well.. you can make use of the built in 'Format' function.. please refer to below code segment..

        Code:
          Format(1000.00, "##,##0.00")

        Comment

        • str1ker
          New Member
          • Jun 2006
          • 23

          #5
          Thanks. Thats all I need now. :)

          Comment

          Working...