01.
Function
getcus()
As
Integer
02.
If
con.State = ConnectionState.Closed
Then
03.
con.Open()
04.
End
If
05.
Try
06.
Dim
Ole
As
String
=
"SELECT MAX(Cus_id)FORM Customer"
07.
Dim
com
As
New
OleDbCommand(Ole, con)
08.
09.
10.
Dim
max
As
Integer
= com.ExecuteScalar
11.
Return
max + 1
12.
Catch
ex
As
Exception
13.
Return
1001
14.
End
Try
15.
16.
End
Function
17.
18.
Private
Sub
add_Click(sender
As
System.
Object
, e
As
System.EventArgs)
Handles
addButton.Click
19.
Cus_IDTextBox.Text =
"C"
& getcus()
20.
21.
Me
.CustomerBindingSource.AddNew()
22.
Call
read()
23.
24.
Cus_IDTextBox.Focus()
25.
26.
End
Sub