Public Class clsFunction
Function
GetNextNumber(ByVal strBefore As String) As String
Dim
temp1 As String
= vbNullString
Dim
lnStrBefore, lnTemp1 As Integer
temp1 = Val(strBefore) + 1
lnStrBefore = Len(strBefore)
lnTemp1 = Len(temp1)
If
lnStrBefore > lnTemp1 Then
Dim
a As Integer
For
a = lnTemp1 To (lnStrBefore - 1)
temp1 = "0" & temp1
Next
End If
Return
temp1
End Function
Function
GetNextString(ByVal strBefore As String) As String
Dim
strAwal As String
= vbNullString
Dim
temp1 As String
= vbNullString
Dim
lnStrBefore As Integer
lnStrBefore = Len(strBefore)
Dim
a, b As Integer
Dim
cKarakter As String
b = lnStrBefore + 1
For a
= 1 To lnStrBefore
b = b - 1
cKarakter = Mid(strBefore, b, 1)
If
IsNumeric(cKarakter) = False Then
strAwal = Left(strBefore, b)
temp1 = Right(strBefore, a -
1)
temp1 = strAwal &
GetNextNumber(temp1)'CALLFUNCTION GetNextNumber
Exit
For
End
If
Next
Return
temp1
End Function
Function
FlexibleAutoNumber(ByVal strRecentNumber As String) As String
If
IsNumeric(strRecentNumber) Then
Return
GetNextNumber(strRecentNumber)
Else
Return
GetNextString(strRecentNumber)
End If
End Function
End Class
|