by Prasenjit Chatterjee (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 4th September 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)
The function getstrnum(num,width) will convert an integer into a "string number" of specified length in the width field.
API Declarations
'If u want to generate 0001,0002,...,0100,0101,....etc
'you have to put x=getstrnum(n,4),where n varies.
Dim c, r As Integer
flag = 0
c = 0
While val <> 0
r = val Mod 10
val = val \ 10
c = c + 1
Wend
numdigit = c
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function getstrnum(ByVal num As Integer, ByVal width As Integer) As String
Dim nx As Integer
Dim strx, strxy As String
Dim i As Integer
strx = "0"
nx = width - numdigit(num)
For i = 1 To nx - 1
strx = strx & "0"
Next i
If numdigit(num) < width Then
strx = strx & num
Else
strx = num
End If
getstrnum = strx
End Function
No comments have been posted about The function getstrnum(num,width) will convert an integer into a string number of specified lengt. Why not be the first to post a comment about The function getstrnum(num,width) will convert an integer into a string number of specified lengt.