📄 module1.bas
字号:
Attribute VB_Name = "Module1"
Public fMainForm As frmMain
Public gintMode As Integer
Public flagEdit As Boolean
Public PWD As String
Public CONN As String
Public UserName As String
Public mrc As ADODB.Connection
Sub Main()
Dim fLogin As New frmLogin
fLogin.Show vbModal
If Not fLogin.OK Then
'Login Failed so exit app
End
End If
Unload fLogin
Set fMainForm = New frmMain
fMainForm.Show
End Sub
Public Function ConnectString() _
As String
'returns a DB ConnectString
ConnectString = "FileDSN=lydiatao.dsn;UID=lydiatao;PWD=820413"
End Function
Public Function ExecuteSQL(ByVal SQL _
As String, MsgString As String) _
As ADODB.Recordset
'executes SQL and returns Recordset
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim sTokens() As String
'异常处理
On Error GoTo ExecuteSQL_Error
'用函数产生一个包含各个子串的数组
sTokens = Split(SQL)
Set cnn = New ADODB.Connection
'打开连接
cnn.Open ConnectString
If InStr("INSERT,DELETE,UPDATE", _
UCase$(sTokens(0))) Then
cnn.Execute SQL
MsgString = sTokens(0) & _
" query successful"
Else
Set rst = New ADODB.Recordset
rst.Open Trim$(SQL), cnn, _
adOpenKeyset, _
adLockOptimistic
'rst.MoveLast 'get RecordCount
'返回记录集对象
Set ExecuteSQL = rst
MsgString = "查询到" & rst.RecordCount & _
" 条记录 "
End If
ExecuteSQL_Exit:
Set rst = Nothing
Set cnn = Nothing
Exit Function
'错误信息
ExecuteSQL_Error:
MsgString = "查询错误: " & _
Err.Description
Resume ExecuteSQL_Exit
End Function
'将enter换成tab
Public Sub EnterToTab(Keyasc As Integer)
' 判断是否为回车键
If Keyasc = 13 Then
SendKeys "{TAB}"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -