Public Sub CalculateNewRecordNumber(ByVal record As String) Dim data As String() = record.Split("-"c) Dim currentDate As DateTime = DateTime.Today Dim recordYear As Integer = Integer.Parse(data(0)) recordYear = Integer.Parse("20" & recordYear) Dim recordMonth As Integer = Integer.Parse(data(1)) If currentDate.Year = recordYear Then If currentDate.Month = recordMonth Then Dim number As Integer = Integer.Parse(data(2)) number += 1 record = recordYear & recordMonth & "-" Dim _recNumberOnly As String = number.ToString() For i As Integer = 0 To 4 - 1 If _recNumberOnly.Length = 4 Then Exit For Else _recNumberOnly = "0" & _recNumberOnly End If Next record += _recNumberOnly Else recordMonth += 1 record = recordYear & recordMonth & "-0001" End If Else recordYear += 1 record = recordYear & "08-0001" End If End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)