Results 1 to 5 of 5

Thread: Grouping digits of a number in Indian currency format

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    1

    Thumbs down Grouping digits of a number in Indian currency format

    In visual basic (not in .Net) how can I represent numbers in Indian currency format.

    For e.g., 12,34,56,789.00 inspite of 123,456,789.00

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Grouping digits of a number in Indian currency format

    Thread moved from the FAQ forum, which is not the place to post your questions.

  3. #3

  4. #4
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Grouping digits of a number in Indian currency format

    Click link in sig

  5. #5
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: Grouping digits of a number in Indian currency format

    Below is my single-line function. It works on any number in Currency range with or without fraction, negative or positive.
    Code:
    Function FormatINR(ByVal Amount As Currency, _
                       Optional ByVal DigitsAfterDot As Byte = 2) As String
       '-- Convert Amount to Indian Currency format: ##,##,##,##,##,##,##0.00
       FormatINR = Format(Amount, Replace(Space((Len(Str(Fix(Amount))) - 3) \ 2), " ", "##\,") _
                   & "##0" & String(-(DigitsAfterDot > 0), ".") & String(DigitsAfterDot, "0"))
    End Function
    Code:
    Sub Test()
       Debug.Print FormatINR(123456789012345.67@)
       Debug.Print FormatINR(123456.78@, 0)
       Debug.Print FormatINR(-123456.78@)
    End Sub
    12,34,56,78,90,12,345.67
    1,23,457
    -1,23,456.78
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

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