📄 common.bas
字号:
Attribute VB_Name = "Common"
Public Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Public Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Public Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Type Dat '自定义类型
'为了和坐标配合,把变量设置为整数型
sx As Integer '存扫描头次遇到非背景色的X坐标
ex As Integer '存扫描非背景色结束的X坐标
sy As Integer 'Y坐标的开始
ey As Integer 'Y坐标的结束
End Type
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Rgn1, Rgn2 As Long
Public m_sql As String
Public m_Conn As String
Public m_AdoConn As ADODB.Connection
Public m_AdoResult As ADODB.Recordset
Public m_AdoCmd As ADODB.Command
Public m_AdoConnString As String
''''''''''
Public m_DaoSql As String
'''用Ado技术连接数据库'''
Sub ConnectionToDatabase()
Set m_AdoConn = New ADODB.Connection
m_Conn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=RongPin2004;Data Source=ntserver"
m_AdoConn.Open m_Conn
''''"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DangAn.mdb;Persist Security Info=False"
End Sub
''''查询房屋信息表中记录数'''''
Function GetRecordCount() As Long
'''连接数据库''''''
Call ConnectionToDatabase
Set m_AdoCmd = New ADODB.Command
Set m_AdoResult = New ADODB.Recordset
m_AdoCmd.ActiveConnection = m_AdoConn
m_AdoCmd.CommandText = "select * from HouseInfo"
m_AdoResult.CursorLocation = adUseClient
m_AdoResult.Open m_AdoCmd, , adOpenDynamic, adLockOptimistic
If m_AdoResult.RecordCount <> 0 Then
GetRecordCount = m_AdoResult.RecordCount
Else
GetRecordCount = 0
End If
End Function
Public Function ExecuteSQL(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
connectstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DangAn.mdb;Persist Security Info=False"
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
Public Sub Sendkey(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
KeyAscii = 0
End If
End Sub
''''''查询指定案卷号的记录是否存在''''
Public Sub 案卷号_Exists(aj_Hao As String)
ConnectionToDatabase
Set m_AdoResult = ExecuteSQL("select * from j案卷目录 where 案卷号='" & Trim(aj_Hao) & "'", "")
If m_AdoResult.RecordCount <> 0 Then
MsgBox "此案卷号已经存在..."
Else
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -