Dear all,
I used to code keypress event for VB6 as below. But now I can't upgrade this code to VBdot net 2003. Can any one help me please, to sort out the code to match VB dot net 2003?
Thanks for your help..
I used to code keypress event for VB6 as below. But now I can't upgrade this code to VBdot net 2003. Can any one help me please, to sort out the code to match VB dot net 2003?
Thanks for your help..
VB.NET:
Private Sub DataGrid1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
KeyAscii = 0
DataGrid1.Refresh
cons.Connect
On Error Resume Next
strsql = "Select * from ProductMaster where Prodcode='" & DataGrid1.Columns(0).Text & "'"
Set rst = New ADODB.Recordset
rst.Open strsql, Conn, adOpenKeyset, adLockOptimistic
If rst.RecordCount <= 0 Or rst.BOF Or rst.EOF Then
MsgBox DataGrid1.Columns(0).Text + " Not found in register"
On Error Resume Next
Exit Sub
End If
If DataGrid1.Col = 0 Then
DataGrid1.Columns(1).Text = rst(1)
DataGrid1.Columns(2).Text = rst(3)
SendKeys "{TAB}" + "{TAB}" + "{TAB}", True
ElseIf DataGrid1.Col = 3 Then
DataGrid1.Columns(4).Text = DataGrid1.Columns(2).Text * DataGrid1.Columns(3).Text
On Error Resume Next
Adodc1.Recordset.Requery
Call sumtotal
SendKeys "{PGDN}", True
End If
End If
cons.Disconnect
End Sub