📄 module1.bas
字号:
Attribute VB_Name = "Module1"
'Public Declare Function MapPhysToLin Lib "WinIo.dll" (ByVal PhysAddr As Long, ByVal PhysSize As Long, ByRef PhysMemHandle) As Long
'Public Declare Function UnmapPhysicalMemory Lib "WinIo.dll" (ByVal PhysMemHandle, ByVal LinAddr) As Boolean
'Public Declare Function GetPhysLong Lib "WinIo.dll" (ByVal PhysAddr As Long, ByRef PhysVal As Long) As Boolean
'Public Declare Function SetPhysLong Lib "WinIo.dll" (ByVal PhysAddr As Long, ByVal PhysVal As Long) As Boolean
'Public Declare Function GetPortVal Lib "WinIo.dll" (ByVal PortAddr As Integer, ByRef PortVal As Long, ByVal bSize As Byte) As Boolean
'Public Declare Function SetPortVal Lib "WinIo.dll" (ByVal PortAddr As Integer, ByVal PortVal As Long, ByVal bSize As Byte) As Boolean
'Public Declare Function InitializeWinIo Lib "WinIo.dll" () As Boolean
'Public Declare Function ShutdownWinIo Lib "WinIo.dll" () As Boolean
'Public Declare Function InstallWinIoDriver Lib "WinIo.dll" (ByVal DriverPath As String, ByVal Mode As Integer) As Boolean
'Public Declare Function RemoveWinIoDriver Lib "WinIo.dll" () As Boolean
Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public nobuf, kNOb0, kNOb00, kNOb1, kNOb11, ykb, Formb0 As Integer
Public icflag As Integer
Public sqlstr, MsgStr As String
Public sfno As String
Public mconn As ADODB.Connection
Public rs1, rs2 As ADODB.Recordset
'数据库执行
Public Function ExecuteSQL(ByVal Sql As String, MsgString As String) As ADODB.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 "dsn=tc00;password=;user id=sa"
If InStr("INSERT,DELETE,UPDATE,Execute", UCase$(sTokens(0))) Then
cnn.Execute Sql
Else
Set Rst = New ADODB.Recordset
Rst.Open Trim$(Sql), cnn, adOpenKeyset, adLockOptimistic
Set ExecuteSQL = Rst
MsgString = "查询到" & Rst.RecordCount & "条记录"
End If
ExecuteSQL_Exit:
Set Rst = Nothing
Set cnn = Nothing
Exit Function
ExecuteSQL_Error:
Resume ExecuteSQL_Exit
End Function
'数据库执行
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -