dj__jebus
asked on
Keeping a number as a lenth=4 string
I have a string called CustomerID and I need it in the format 0003, 0014 etc... this is what I have, but my problem is if I enter a number say 13 it gives me 00013 when I really want 0013. It is the select case part of the function that the problem lays I think.
'Creates a new JobID
Public Function NewJobID() As String
Dim JobID As String, Counter As Single
JobID = LastJobID + 1
LastJobID = LastJobID + 1
Call UpdateLastIDs
Select Case JobID
Case 1 To 9
NewJobID = "000" & JobID
Case 10 To 99
NewJobID = "00" & JobID
Case 100 To 999
NewJobID = "0" & JobID
Case 1000 To 9999
NewJobID = JobID
End Select
End Function
Thanks, Jebus
'Creates a new JobID
Public Function NewJobID() As String
Dim JobID As String, Counter As Single
JobID = LastJobID + 1
LastJobID = LastJobID + 1
Call UpdateLastIDs
Select Case JobID
Case 1 To 9
NewJobID = "000" & JobID
Case 10 To 99
NewJobID = "00" & JobID
Case 100 To 999
NewJobID = "0" & JobID
Case 1000 To 9999
NewJobID = JobID
End Select
End Function
Thanks, Jebus
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BTW FormatNum is a string variable and Ret is an integer variable
ASKER