模块代码看不懂
来源:百度知道 编辑:UC知道 时间:2024/09/22 21:36:03
Public Function GetRs(ByVal strQurey As String) As ADODB.Recordset
Dim rs As New ADODB.Recordset
Dim conn As New ADODB.Connection
On Error GoTo GetRs_error
Set conn = CurrentProject.Connection
rs.Open strQurey, conn, adOpenKeyset, adLockOptimistic
Set GetRs = rs
GetRs_Exit:
Set rs = Nothing
Set conn = Nothing
Exit Function
GetRs_error:
MsgBox (Err.Description)
Resume GetRs_Exit
End Function
Public Sub ExecuteSql(ByVal strCmd As String)
Dim conn As New ADODB.Connection
On Error GoTo ExecuteSQL_Error
Set conn = CurrentProject.Connection
conn.Execute Trim$(strCmd)
ExecuteSQL_Exit:
Set conn = Nothing
Exit Sub
ExecuteSQL_Error:
MsgBox (Err.Description)
Resume ExecuteSQL_Exit
End Sub
Public Sub EnterToTab(keyasc As String)
If keyasc = 13 Then
SendKeys "{TAB}"
End If
End Sub
这3段模块中的
Dim rs As New ADODB.Recordset
Dim conn As New ADODB.Connection
On Error GoTo GetRs_error
Set conn = CurrentProject.Connection
rs.Open strQurey, conn, adOpenKeyset, adLockOptimistic
Set GetRs = rs
GetRs_Exit:
Set rs = Nothing
Set conn = Nothing
Exit Function
GetRs_error:
MsgBox (Err.Description)
Resume GetRs_Exit
End Function
Public Sub ExecuteSql(ByVal strCmd As String)
Dim conn As New ADODB.Connection
On Error GoTo ExecuteSQL_Error
Set conn = CurrentProject.Connection
conn.Execute Trim$(strCmd)
ExecuteSQL_Exit:
Set conn = Nothing
Exit Sub
ExecuteSQL_Error:
MsgBox (Err.Description)
Resume ExecuteSQL_Exit
End Sub
Public Sub EnterToTab(keyasc As String)
If keyasc = 13 Then
SendKeys "{TAB}"
End If
End Sub
这3段模块中的
没用过vb的人回答一下:
代码功能:
1.连接数据库,获得记录集
2.执行sql语句
3.将enter按键转换成tab键
如有误望vb达人指正
建议搂主看看基本的vb书籍-_-||