📄 frmfind.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmFind
BorderStyle = 4 'Fixed ToolWindow
Caption = "查找学生"
ClientHeight = 4455
ClientLeft = 45
ClientTop = 285
ClientWidth = 3870
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4455
ScaleWidth = 3870
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Caption = "查找结果 双击定位"
Height = 3180
Left = 45
TabIndex = 8
Top = 1230
Width = 3735
Begin MSComctlLib.ListView ListView1
Height = 2880
Left = 30
TabIndex = 9
Top = 225
Width = 3615
_ExtentX = 6376
_ExtentY = 5080
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = -1 'True
FullRowSelect = -1 'True
GridLines = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 3
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "ID"
Object.Width = 1058
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "姓名"
Object.Width = 1411
EndProperty
BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 2
Text = "班级号"
Object.Width = 1411
EndProperty
End
End
Begin VB.CommandButton Command2
Caption = "重填"
Height = 405
Left = 2295
TabIndex = 7
Top = 690
Width = 1470
End
Begin VB.CommandButton Command1
Caption = "查找"
Height = 405
Left = 2295
TabIndex = 6
Top = 150
Width = 1455
End
Begin VB.TextBox Text3
Height = 285
Left = 615
TabIndex = 5
Top = 840
Width = 1530
End
Begin VB.TextBox Text2
Height = 285
Left = 615
TabIndex = 4
Top = 465
Width = 1530
End
Begin VB.TextBox Text1
Height = 285
Left = 615
TabIndex = 3
Top = 120
Width = 1530
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "姓名:"
Height = 180
Left = 90
TabIndex = 2
Top = 855
Width = 540
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "学号:"
Height = 180
Left = 75
TabIndex = 1
Top = 495
Width = 540
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "ID:"
Height = 180
Left = 255
TabIndex = 0
Top = 165
Width = 360
End
Begin VB.Menu m_main
Caption = "m_main"
Visible = 0 'False
Begin VB.Menu m_find
Caption = "定位学生(&F)"
End
End
End
Attribute VB_Name = "frmFind"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Dim rec As New ADODB.Recordset, sql As String
If Not Text1 = "" Then
sql = sql & "ID=" & Text1 & " "
End If
If Not Text2 = "" Then
sql = sql & "and number=" & Text2 & " "
End If
If Not Text3 = "" Then
sql = sql & "and name like '%" & Text3 & "%'"
End If
If sql = "" Then
MsgBox "请至少填一项!"
Exit Sub
End If
If Left(sql, 3) = "and" Then
sql = Mid(sql, 4)
End If
rec.Open "select ID,Name,Class from [tblInfos] where " & sql, Con
With ListView1.ListItems
.Clear
Do While Not (rec.EOF Or rec.BOF)
With .Add(, , rec("ID"))
.ListSubItems.Add , , rec("name")
.ListSubItems.Add , , rec("class")
End With
rec.MoveNext
Loop
End With
rec.Close
Set rec = Nothing
End Sub
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text3 = ""
End Sub
Private Sub ListView1_DblClick()
On Error Resume Next
m_find_Click
End Sub
Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
On Error Resume Next
If Button <> 2 Then Exit Sub
With ListView1.HitTest(x, y)
.Selected = True
Me.PopupMenu m_main
End With
End Sub
Private Sub m_find_Click()
Dim i As Integer
With frmMain.Adodc1
.Recordset.MoveFirst
For i = 0 To .Recordset.RecordCount - 1
If .Recordset(0) = ListView1.SelectedItem.Text Then
GoTo ok
End If
.Recordset.MoveNext
Next
End With
MsgBox "你当前浏览的表中无此人!"
ok:
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -