by Humberto Martinez (2 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 5th September 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Ever had a number like this one "205" and wanted to add zeros to the left ("000205")? well now you can.. with this simple function you can
Dim Factor As Double
Dim AddZero As Integer
Dim Aux As String
Dim I as integer
If Pos > 1 Then
Pos = Pos - 1
Factor = 10 ^ Pos
If N < Factor Then
AddZero = (Pos + 1) - Len(Trim(N))
For I = 1 To AddZero
Aux = Aux & "0"
Next I
Aux = Aux & N
Else
Aux = N
End If
Else
Aux = N
End If
NFormat = Aux
End Function
'You can call the function like this
'Text1 = NFormat(MyNumber, NumberOfPositions)
No comments have been posted about Ever had a number like this one 205 and wanted to add zeros to the left (000205)? well now you . Why not be the first to post a comment about Ever had a number like this one 205 and wanted to add zeros to the left (000205)? well now you .