📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3840
ClientLeft = 60
ClientTop = 345
ClientWidth = 5865
LinkTopic = "Form1"
ScaleHeight = 3840
ScaleWidth = 5865
StartUpPosition = 2 'CenterScreen
Begin VB.TextBox Text2
Height = 375
Left = 240
TabIndex = 7
Top = 720
Width = 3735
End
Begin VB.CommandButton Command2
Caption = "下一条"
Enabled = 0 'False
Height = 375
Left = 4440
TabIndex = 6
Top = 2400
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "查询"
Height = 375
Left = 4440
TabIndex = 5
Top = 240
Width = 1095
End
Begin VB.TextBox Text5
Height = 375
Left = 240
TabIndex = 3
Top = 2160
Width = 3735
End
Begin VB.TextBox Text4
Height = 375
Left = 240
TabIndex = 2
Top = 1680
Width = 3735
End
Begin VB.TextBox Text3
Height = 375
Left = 240
TabIndex = 1
Top = 1200
Width = 3735
End
Begin VB.TextBox Text1
Height = 375
Left = 240
TabIndex = 0
Top = 240
Width = 3735
End
Begin VB.OLE OLE1
Class = "Package"
Height = 1095
Left = 4200
OleObjectBlob = "Form1.frx":0000
SourceDoc = "E:\kkk\Secured.mdw"
TabIndex = 8
Top = 960
Visible = 0 'False
Width = 1335
End
Begin VB.Label Label1
Caption = "Label1"
Height = 375
Left = 240
TabIndex = 4
Top = 3120
Width = 5295
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim aco As ADODB.Connection
Dim rsItem As ADODB.Recordset
Dim sSysPath As String
'新添加内容
Private Function AddUser(ByVal strUser As String, ByVal strPID As String, Optional ByVal strPwd As String) As Boolean
End Function
Private Sub Command1_Click()
Dim strSQL As String
Label1.Caption = ""
If rsItem.State = adStateOpen Then
rsItem.Close
End If
If Text1.Text <> "" Then
strSQL = strSQL & "maozedong LIKE '%" & Text1.Text & "%' "
End If
If Text2.Text <> "" Then
If strSQL = "" Then
strSQL = strSQL & "maozedong LIKE '%" & Text2.Text & "%' "
Else
strSQL = strSQL & "AND maozedong LIKE '%" & Text2.Text & "%' "
End If
End If
If Text3.Text <> "" Then
If strSQL = "" Then
strSQL = strSQL & "maozedong LIKE '%" & Text3.Text & "%' "
Else
strSQL = strSQL & "AND maozedong LIKE '%" & Text3.Text & "%' "
End If
End If
If Text4.Text <> "" Then
If strSQL = "" Then
strSQL = strSQL & "maozedong LIKE '%" & Text4.Text & "%' "
Else
strSQL = strSQL & "AND maozedong LIKE '%" & Text4.Text & "%' "
End If
End If
If Text5.Text <> "" Then
If strSQL = "" Then
strSQL = strSQL & "maozedong LIKE '%" & Text5.Text & "%' "
Else
strSQL = strSQL & "AND maozedong LIKE '%" & Text5.Text & "%' "
End If
End If
If strSQL = "" Then
strSQL = "SELECT * FROM table1"
Else
strSQL = "SELECT * FROM table1 WHERE " & strSQL
End If
rsItem.Open strSQL
If Not rsItem.EOF Then
Label1.Caption = rsItem.Fields("maozedong")
Command2.Enabled = True
End If
End Sub
Private Sub Command2_Click()
rsItem.MoveNext
If Not rsItem.EOF Then
Label1.Caption = rsItem.Fields("maozedong")
Else
MsgBox "没有记录了。", vbInformation
Command2.Enabled = False
rsItem.Close
End If
End Sub
'生成临时文件
Private Sub GernerateRESFile()
Dim FileNum As Integer
Dim sFile As String
Dim bytImage() As Byte
sFile = sSysPath & "\abcd.abc"
bytImage = LoadResData(104, "ACCRES")
FileNum = FreeFile
Open sFile For Binary As #FileNum
Put #FileNum, , bytImage
Close #FileNum
End Sub
Private Sub Form_Load()
'获取系统目寻 begin
Dim s As String * 80
Dim Length As Long
Length = GetSystemDirectory(s, Len(s))
sSysPath = Left(s, Length)
' end
Set aco = CreateObject("ADODB.Connection")
aco.Provider = "Microsoft.Jet.OLEDB.4.0"
'aco.Properties("User ID") = "wolf"
'aco.Properties("Jet OLEDB:Database Password") = "13024312829"
aco.Properties("Data Source") = App.Path & "\db1.mdb"
' aco.Properties("Jet OLEDB:System database") = App.Path & "\Secured.mdw"
GernerateRESFile
aco.Properties("Jet OLEDB:System database") = sSysPath & "\abcd.abc"
'aco.Open
aco.Open UserID:="wolf", Password:="13024312829"
Set rsItem = New ADODB.Recordset
With rsItem
.ActiveConnection = aco
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
End With
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If rsItem.State = adStateOpen Then
rsItem.Close
End If
Set rsItem = Nothing
aco.Close
Set aco = Nothing
End Sub
Private Sub Form_Unload(Cancel As Integer)
Kill sSysPath & "\abcd.abc"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -