📄 search.frm
字号:
VERSION 5.00
Begin VB.Form search
Caption = "查询"
ClientHeight = 5655
ClientLeft = 60
ClientTop = 345
ClientWidth = 6525
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 5655
ScaleWidth = 6525
WindowState = 2 'Maximized
Begin VB.OptionButton Option1
Caption = "而且"
Height = 255
Left = 480
TabIndex = 21
Top = 840
Width = 855
End
Begin VB.OptionButton Option2
Caption = "或者"
Height = 255
Left = 2160
TabIndex = 20
Top = 840
Width = 1095
End
Begin VB.ListBox List1
Height = 1320
Left = 480
TabIndex = 19
Top = 1200
Width = 4575
End
Begin VB.CommandButton Command5
Caption = "删除"
Height = 495
Left = 5280
TabIndex = 18
Top = 1920
Width = 1095
End
Begin VB.CommandButton ExpAdd
Caption = "添加"
Height = 495
Left = 5280
TabIndex = 17
Top = 1320
Width = 1095
End
Begin VB.CommandButton Command4
Caption = "退出"
Height = 495
Left = 4680
TabIndex = 15
Top = 4320
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "继续查找"
Height = 495
Left = 4680
TabIndex = 9
Top = 3720
Width = 1215
End
Begin VB.TextBox Text6
DataField = "总成绩"
DataSource = "Data1"
Height = 375
Left = 2280
TabIndex = 8
Text = "Text6"
Top = 4800
Width = 1335
End
Begin VB.TextBox Text5
DataField = "年龄"
DataSource = "Data1"
Height = 375
Left = 2280
TabIndex = 7
Text = "Text5"
Top = 4320
Width = 1335
End
Begin VB.TextBox Text4
DataField = "性别"
DataSource = "Data1"
Height = 375
Left = 2280
TabIndex = 6
Text = "Text4"
Top = 3840
Width = 1335
End
Begin VB.TextBox Text3
DataField = "姓名"
DataSource = "Data1"
Height = 375
Left = 2280
TabIndex = 5
Text = "Text3"
Top = 3360
Width = 1335
End
Begin VB.TextBox Text2
DataField = "学号"
DataSource = "Data1"
Height = 375
Left = 2280
TabIndex = 4
Text = "Text2"
Top = 2880
Width = 1335
End
Begin VB.CommandButton Command2
Caption = "查找"
Height = 495
Left = 4680
TabIndex = 3
Top = 3120
Width = 1215
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = "stu.mdb"
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 495
Left = 840
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "student"
Top = 5400
Visible = 0 'False
Width = 3735
End
Begin VB.TextBox Text1
Height = 315
Left = 3000
TabIndex = 2
Text = "Text1"
Top = 480
Width = 2055
End
Begin VB.ComboBox Combo2
Height = 330
Left = 1680
Style = 2 'Dropdown List
TabIndex = 1
Top = 480
Width = 1335
End
Begin VB.ComboBox Combo1
Height = 330
Left = 480
Style = 2 'Dropdown List
TabIndex = 0
Top = 480
Width = 1215
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "请选择查找条件"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 480
TabIndex = 16
Top = 120
Width = 1590
End
Begin VB.Line Line1
BorderColor = &H00FF00FF&
BorderWidth = 2
X1 = 0
X2 = 6600
Y1 = 2760
Y2 = 2760
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "学号"
Height = 210
Left = 1140
TabIndex = 14
Top = 3000
Width = 420
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "姓名"
Height = 210
Left = 1140
TabIndex = 13
Top = 3480
Width = 420
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "年龄"
Height = 210
Left = 1140
TabIndex = 12
Top = 4440
Width = 420
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "性别"
Height = 210
Left = 1140
TabIndex = 11
Top = 3960
Width = 420
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "总成绩"
Height = 210
Left = 960
TabIndex = 10
Top = 4920
Width = 630
End
End
Attribute VB_Name = "search"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim FindStr As String
Private Sub Command1_Click()
End Sub
Private Sub Command2_Click()
On Error Resume Next
FindStr = ""
Dim i As Integer
For i = 0 To List1.ListCount - 1
FindStr = FindStr & List1.List(i)
Next i
FindStr = LTrim(FindStr)
Data1.Recordset.FindFirst FindStr
If Data1.Recordset.NoMatch Then
MsgBox "没有找到符合条件的数据", , "查找"
Command3.Enabled = False
Exit Sub
Else
Command3.Enabled = True
End If
End Sub
Private Sub Command3_Click()
On Error Resume Next
Data1.Recordset.FindNext FindStr
If Data1.Recordset.NoMatch Then
MsgBox "查找结束", , "查找"
Command3.Enabled = False
Exit Sub
End If
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Command5_Click()
If List1.ListIndex < 0 Then
MsgBox "请先选择被删除项", , "删除查询条件"
Exit Sub
Else
List1.RemoveItem List1.ListIndex
List1.List(0) = Space(5) + Mid(List1.List(0), 6)
End If
End Sub
Private Sub ExpAdd_Click()
Dim SQLS As String
Dim And_Or As String
And_Or = " "
If Combo1.Text = "学号" Or Combo1.Text = "性别" Or Combo1.Text = "姓名" Then
SQLS = Combo1.Text & " " & Combo2.Text & "'" & Trim(Text1.Text) & "'"
Else
SQLS = Combo1.Text & " " & Combo2.Text & Trim(Text1.Text)
End If
If Option1.Value Then And_Or = " and "
If Option2.Value Then And_Or = " OR "
List1.AddItem And_Or & SQLS
Option1.Visible = True
Option2.Visible = True
Option1.Value = True
End Sub
Private Sub Form_Load()
Dim db As Database
Dim rst As Recordset
Dim i As Integer
Dim DBStr As String
DBStr = App.Path
If Right(App.Path, 1) <> "\" Then DBStr = App.Path & "\"
DBStr = DBStr & "stu.mdb"
Data1.DatabaseName = DBStr
Set db = OpenDatabase(DBStr)
Set rst = db.OpenRecordset("student")
For i = 0 To rst.Fields.count - 1
Combo1.AddItem (rst.Fields(i).Name)
Next i
Combo2.AddItem "="
Combo2.AddItem ">"
Combo2.AddItem ">="
Combo2.AddItem "<"
Combo2.AddItem "<="
Combo2.AddItem "<>"
Combo2.AddItem "Like"
Combo1.Text = "学号"
Combo2.Text = "="
Text1.Text = ""
Command3.Enabled = False
Option1.Visible = False
Option2.Visible = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -