Dim Cn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Private Sub Command1_Click()
Adodc1.Recordset.AddNew
Command1.Enabled = False
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = False
Text1(0).SetFocus
End Sub
Private Sub Command2_Click()
Adodc1.Recordset.Update
Adodc1.Refresh
Command1.Enabled = True
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = True
DataGrid1.Refresh
End Sub
Private Sub Command3_Click()
Adodc1.Recordset.CancelUpdate
Command1.Enabled = True
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = True
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Load()
Set Cn = New ADODB.Connection
Cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Visual Basic\EG\12-14\rkd.mdb;Persist Security Info=False"
Cn.Open
Adodc1.ConnectionString = Cn
Adodc1.RecordSource = "rkd"
Adodc1.Refresh
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
Select Case Index
Case 0
If KeyCode = vbKeyReturn Then
Text1(1).SetFocus
End If
Case 1
If KeyCode = vbKeyReturn Then
Text1(2).SetFocus
End If
If KeyCode = vbKeyUp Then
Text1(0).SetFocus
End If
Case 2
If KeyCode = vbKeyReturn Then
Text1(3).SetFocus
End If
If KeyCode = vbKeyUp Then
Text1(1).SetFocus
End If
Case 3
If KeyCode = vbKeyReturn Then
Text1(4).SetFocus
End If
If KeyCode = vbKeyUp Then
Text1(2).SetFocus
End If
Case 4
If KeyCode = vbKeyReturn Then
Text1(5).SetFocus
End If
If KeyCode = vbKeyUp Then
Text1(3).SetFocus
End If
Case 5
If KeyCode = vbKeyReturn Then
Text1(6).Text = Val(Text1(5).Text) * Val(Text1(4).Text)
Text1(6).SetFocus
End If
If KeyCode = vbKeyUp Then
Text1(4).SetFocus
End If
Case 6
If KeyCode = vbKeyReturn Then
Text1(7).SetFocus
End If
If KeyCode = vbKeyUp Then
Text1(5).SetFocus
End If
Case 7
If KeyCode = vbKeyReturn Then
Command2.SetFocus
End If
If KeyCode = vbKeyUp Then
Text1(7).SetFocus
End If
End Select