Private Sub Debit_ID()
Dim sql As String = "Select max(Debit_ID) from Debit"
Dim com As New OleDbCommand(sql, conn)
Dim max As Integer = com.ExecuteScalar
If max > 0 Then
txtDebitID.Text = Microsoft.VisualBasic.Right("000000" & max, 7) & "DB"
Else
txtDebitID.Text = "0000001DB"
End If
End Sub
Private Sub Debit_ID()
Dim sql As String = "Select max(Debit_ID) from Debit"
Dim com As New OleDbCommand(sql, conn)
Dim max As Integer = com.ExecuteScalar
If max > 0 Then
txtDebitID.Text = AddPrefix(max+1,'0',7) & "DB"
Else
txtDebitID.Text = "0000001DB"
End If
End Sub
Public Function AddPrefix(ByVal txt As String, ByVal Header As String, ByVal len As Integer) As String
Do While txt.Length < len
txt = Header & txt
Loop
Return txt
End Function