📄 frmcon.frm
字号:
VERSION 5.00
Begin VB.Form frmCon
BorderStyle = 3 'Fixed Dialog
Caption = "查询条件"
ClientHeight = 3315
ClientLeft = 45
ClientTop = 330
ClientWidth = 5715
Icon = "frmCon.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3315
ScaleWidth = 5715
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.ComboBox comE2
Height = 300
Left = 1440
Style = 2 'Dropdown List
TabIndex = 22
Top = 2475
Width = 630
End
Begin VB.CommandButton Command2
Caption = "取消查询"
Height = 390
Left = 3465
TabIndex = 21
Top = 2850
Width = 2190
End
Begin VB.CommandButton Command1
Caption = "查询此人"
Height = 375
Left = 3465
TabIndex = 20
Top = 2325
Width = 2190
End
Begin VB.ComboBox comFrom
Height = 300
Left = 1440
TabIndex = 18
Text = "Combo4"
Top = 2850
Width = 1785
End
Begin VB.TextBox Text5
Height = 270
Left = 2160
TabIndex = 17
Top = 2490
Width = 1020
End
Begin VB.ComboBox comSP
Height = 300
Left = 1440
TabIndex = 14
Text = "Combo3"
Top = 2100
Width = 1785
End
Begin VB.ComboBox comSys
Height = 300
Left = 1440
TabIndex = 12
Text = "Combo2"
Top = 1695
Width = 1785
End
Begin VB.TextBox Text4
Height = 270
Left = 1440
TabIndex = 10
Top = 1350
Width = 1785
End
Begin VB.TextBox Text3
Height = 300
Left = 3345
TabIndex = 8
Top = 975
Visible = 0 'False
Width = 1755
End
Begin VB.TextBox Text2
Height = 270
Left = 1425
TabIndex = 5
Top = 990
Width = 1515
End
Begin VB.ComboBox comSex
Height = 300
ItemData = "frmCon.frx":08CA
Left = 1440
List = "frmCon.frx":08D4
TabIndex = 3
Text = "comSex"
Top = 585
Width = 1785
End
Begin VB.TextBox Text1
Height = 270
Left = 1440
TabIndex = 0
Top = 270
Width = 1785
End
Begin VB.Label Label11
Alignment = 2 'Center
BackColor = &H00000000&
Caption = "(留空忽略)"
ForeColor = &H000000C0&
Height = 255
Left = 180
TabIndex = 19
Top = 15
Width = 5355
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "生源:"
Height = 180
Left = 945
TabIndex = 16
Top = 2910
Width = 540
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "入学分数:"
Height = 180
Left = 585
TabIndex = 15
Top = 2535
Width = 900
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "专业:"
Height = 180
Left = 945
TabIndex = 13
Top = 2160
Width = 540
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "系别:"
Height = 180
Left = 945
TabIndex = 11
Top = 1785
Width = 540
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "班级号:"
Height = 180
Left = 765
TabIndex = 9
Top = 1410
Width = 720
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "后"
Height = 180
Left = 5190
TabIndex = 7
Top = 1035
Visible = 0 'False
Width = 180
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "前"
Height = 180
Left = 3060
TabIndex = 6
Top = 1035
Width = 180
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "出生日:"
Height = 180
Left = 765
TabIndex = 4
Top = 1035
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "性别:"
Height = 180
Left = 945
TabIndex = 2
Top = 660
Width = 540
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "姓名包含字符:"
Height = 180
Left = 225
TabIndex = 1
Top = 285
Width = 1260
End
End
Attribute VB_Name = "frmCon"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Dim sql As String
If Not CheckFormats Then
MsgBox "无法查询"
Else
If Text1 <> "" Then
sql = "name like '%" & Text1 & "%' "
End If
If comSex.Text <> "" Then
sql = sql & "and sex='" & comSex.Text & "' "
End If
If Text2 <> "" Then
sql = sql & "and birthday > " & Text2 & " "
End If
If Text4 <> "" Then
sql = sql & "and class=" & Text4 & " "
End If
If comSys.Text <> "" Then
sql = sql & "and system='" & comSys.Text & "' "
End If
If comSP.Text <> "" Then
sql = sql & "and specialty='" & comSP.Text & "' "
End If
If Text5 <> "" Then
sql = sql & "and entach" & comE2.Text & Text5 & " "
End If
If comFrom.Text <> "" Then
sql = sql & "and [from]='" & comFrom.Text & "'"
End If
If Left(sql, 3) = "and" Then
sql = Mid(sql, 4)
End If
If Not Len(sql) > 0 Then
MsgBox "老兄,至少填一个吧!"
Exit Sub
End If
sql = "select " & frmDBSet.txtItem & " from [tblInfos] where " & sql
frmMain.FindInfo sql
Hide
End If
End Sub
Private Function CheckFormats() As Boolean
CheckFormats = False
If InStr(1, Text1, "'") Or InStr(1, Text1, "[") & InStr(1, Text1, "]") Then
MsgBox "姓名里包含非法字符!"
Text1.SetFocus
SendKeys "{Home}+{End}"
Exit Function
End If
If Not (IsDate(Text2) And IsDate(Text3)) Then
If Not IsDate(Text2) And Text2 <> "" Then
MsgBox "日期格式不正确!"
Text2.SetFocus
SendKeys "{Home}+{End}"
Exit Function
ElseIf Not IsDate(Text3) And Text3 <> "" Then
MsgBox "日期格式不正确!"
Text3.SetFocus
SendKeys "{Home}+{End}"
Exit Function
End If
End If
If Not IsNumeric(Text4.Text) And Text4 <> "" Then
MsgBox "班级号必须为数字!"
Text4.SetFocus
SendKeys "{Home}+{End}"
Exit Function
End If
If Not IsNumeric(Text5) And Text5 <> "" Then
MsgBox "入学分数必须为数字!"
Text5.SetFocus
SendKeys "{Home}+{End}"
Exit Function
End If
CheckFormats = True
End Function
Private Sub Command2_Click()
Hide
End Sub
Private Sub Form_Load()
comE2.AddItem ">"
comE2.AddItem "<"
comE2.AddItem "="
comE2.AddItem "<="
comE2.AddItem ">="
comE2.AddItem "<>"
ShowInSB "初始化查询...", "加载性别列表..."
LoadList "sex", comSex
ShowInSB "初始化查询...", "加载系别列表..."
LoadList "system", comSys
ShowInSB "初始化查询...", "加载专业列表..."
LoadList "specialty", comSP
ShowInSB "初始化查询...", "加载生源列表..."
LoadList "from", comFrom
ShowInSB "就绪。", ""
End Sub
Sub LoadList(ByVal ListName As String, ctlCom As ComboBox)
ctlCom.Clear
Dim rec As New ADODB.Recordset
rec.Open "select DISTINCT [" & ListName & "] from [tblInfos]", Con
Do While Not (rec.EOF Or rec.BOF)
ctlCom.AddItem rec(ListName)
rec.MoveNext
Loop
rec.Close
Set rec = Nothing
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -