C
Co
Hi All,
I'm trying to create a function that will create a "reference number"
which is one higher then the latest one added.
The reference number consist of "2009000100"
which is the year (2009) followed by a 6 figur digit "000100"
The code must create the new reference number as : "2009000101"
'oldKenmerk = latest used reference number
Dim i As Integer
Dim numberPart As String
numberPart = Mid(oldKenmerk, 5, 6)
Dim sNumPart As String = ""
For i = 1 To 6
If Mid(numberPart, i, 1) = "0" Then
sNumPart = sNumPart & Mid(numberPart, i, 1)
Else
Exit For
End If
Next
numberPart = Replace(numberPart, sNumPart, "")
If Mid(oldKenmerk, 1, 4) = Year(Today) Then
newKenmerk = Year(Today) & sNumPart & CInt(numberPart) + 1
Else
'the file is the first of the year
newKenmerk = Year(Today) & "000100"
End If
I don't think my code will work when you go from for example
"2009000199" to "2009000200"
Regards
Marco
I'm trying to create a function that will create a "reference number"
which is one higher then the latest one added.
The reference number consist of "2009000100"
which is the year (2009) followed by a 6 figur digit "000100"
The code must create the new reference number as : "2009000101"
'oldKenmerk = latest used reference number
Dim i As Integer
Dim numberPart As String
numberPart = Mid(oldKenmerk, 5, 6)
Dim sNumPart As String = ""
For i = 1 To 6
If Mid(numberPart, i, 1) = "0" Then
sNumPart = sNumPart & Mid(numberPart, i, 1)
Else
Exit For
End If
Next
numberPart = Replace(numberPart, sNumPart, "")
If Mid(oldKenmerk, 1, 4) = Year(Today) Then
newKenmerk = Year(Today) & sNumPart & CInt(numberPart) + 1
Else
'the file is the first of the year
newKenmerk = Year(Today) & "000100"
End If
I don't think my code will work when you go from for example
"2009000199" to "2009000200"
Regards
Marco