VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



'Formats a number into segments, e.g. 123456789 to 123'456'789

by Deano Splamoni (15 Submissions)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 31st July 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

'Formats a number into segments, e.g. 123456789 to 123'456'789

API Declarations


'only does upto 9 characters long but can easily be updated

Rate 'Formats a number into segments, e.g. 123456789 to 123'456'789



On Error Resume Next
Dim a As String, b As String, c As String, _
    strin As String, d As String
    
strin = Str(itsin)
    If Len(itsin) <= 3 Then
        commentit = Str(itsin)
        Exit Function
    End If
    If Len(itsin) <= 6 Then
        a = Mid(strin, Len(strin) - 3, 3)
        b = Mid(strin, 1, Len(strin) - 3)
        c = b & "'" & a
        commentit = c
        Exit Function
    End If
    If Len(itsin) <= 9 Then
        a = Mid(strin, Len(strin) - 3, 3)
        b = Mid(strin, Len(strin) - 6, 3)
        d = Mid(strin, 1, Len(strin) - 6)
        c = d & "'" & b & "'" & a
        commentit = c
        Exit Function
    End If
End Function

Download this snippet    Add to My Saved Code

'Formats a number into segments, e.g. 123456789 to 123'456'789 Comments

No comments have been posted about 'Formats a number into segments, e.g. 123456789 to 123'456'789. Why not be the first to post a comment about 'Formats a number into segments, e.g. 123456789 to 123'456'789.

Post your comment

Subject:
Message:
0/1000 characters