📄 frmcx.frm
字号:
Left = 3960
TabIndex = 10
Top = 720
Width = 615
End
Begin VB.OptionButton Option1
Caption = "男"
Height = 255
Index = 0
Left = 3240
TabIndex = 9
Top = 720
Value = -1 'True
Width = 615
End
Begin VB.TextBox Text1
Height = 270
Index = 0
Left = 960
TabIndex = 8
Top = 240
Width = 1095
End
Begin VB.CheckBox Check1
Caption = "Email"
Height = 255
Index = 10
Left = 120
TabIndex = 7
Top = 3480
Width = 855
End
Begin VB.CheckBox Check1
Caption = "传真"
Height = 255
Index = 9
Left = 120
TabIndex = 6
Top = 3120
Width = 735
End
Begin VB.CheckBox Check1
Caption = "性别"
Height = 255
Index = 3
Left = 2400
TabIndex = 5
Top = 720
Width = 735
End
Begin VB.CheckBox Check1
Caption = "昵称"
Height = 255
Index = 0
Left = 120
TabIndex = 0
Top = 240
Width = 735
End
End
End
Attribute VB_Name = "frmCX"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Check1_Click(Index As Integer)
Dim i As Integer
For i = 0 To 10
Text1(i).Enabled = Check1(i).Value
Next i
'判断性别输入是否有效
Option1(0).Enabled = Check1(3).Value
Option1(1).Enabled = Check1(3).Value
'判断年龄输入是否有效
Frame2.Enabled = Check1(4).Value
For i = 0 To 1
Check2(i).Enabled = Frame2.Enabled
Next i
End Sub
Private Sub Command1_Click() '模糊查询
On Error GoTo ErrHandle
'判断昵称查询
If Check1(0).Value = 1 And Not IsNull(Text1(0).Text) Then
SQLadd = SQLadd + " and Love like'*" + Text1(0).Text + "*'"
End If
'判断QQ查询
If Check1(1).Value = 1 And Not IsNull(Text1(1).Text) Then
SQLadd = SQLadd + " and Oicq like'*" + Text1(1).Text + "*'"
End If
'判断姓名查询
If Check1(2).Value = 1 And Not IsNull(Text1(2).Text) Then
SQLadd = SQLadd + " and Name like'*" + Text1(2).Text + "*'"
End If
'性别查询
If Check1(3).Value = 1 Then
If Option1(0).Value = True Then
SQLadd = SQLadd + " and Sex='" + "男" + "'"
Else
SQLadd = SQLadd + " and Sex='" + "女" + "'"
End If
End If
'年龄查询
If Check1(4).Value = 1 Then
If Check2(0).Value = 1 And IsNumeric(Text2(0).Text) Then
If Check2(1).Value = 1 Then
SQLadd = SQLadd + " and Age<=" + Text2(1).Text
SQLadd = SQLadd + " and Age>=" + Text2(0).Text
Else
SQLadd = SQLadd + " and Age>=" + Text2(0).Text
End If
Else
If Check2(1).Value = 1 Then
SQLadd = SQLadd + " and Age<=" + Text2(1).Text
End If
End If
End If
'判断电话查询
If Check1(5).Value = 1 And Not IsNull(Text1(5).Text) Then
SQLadd = SQLadd + " and TelepNo like'*" + Text1(5).Text + "*'"
End If
'判断手机查询
If Check1(6).Value = 1 And Not IsNull(Text1(6).Text) Then
SQLadd = SQLadd + " and MoveCall like'*" + Text1(6).Text + "*'"
End If
'判断宅电查询
If Check1(7).Value = 1 And Not IsNull(Text1(7).Text) Then
SQLadd = SQLadd + " and Home like'*" + Text1(7).Text + "*'"
End If
'判断传呼查询
If Check1(8).Value = 1 And Not IsNull(Text1(8).Text) Then
SQLadd = SQLadd + " and Call like'*" + Text1(8).Text + "*'"
End If
'判断传真查询
If Check1(9).Value = 1 And Not IsNull(Text1(9).Text) Then
SQLadd = SQLadd + " and Fax like'*" + Text1(9).Text + "*'"
End If
'判断Email查询
If Check1(10).Value = 1 And Not IsNull(Text1(10).Text) Then
SQLadd = SQLadd + " and Email like'*" + Text1(10).Text + "*'"
End If
'更新数据库显示信息
frmData.Data1.DatabaseName = frmData.mdbFile 'App.Path + "\MyNote.mdb"
frmData.Data1.RecordSource = SQLoriginal + SQLadd + SQLorder
frmData.Data1.Refresh
ListRefresh
Unload Me
Exit Sub
ErrHandle:
MsgBox Err.Description
Unload Me
Exit Sub
End Sub
Private Sub Command2_Click() '精确查询
On Error GoTo ErrHandle
'判断昵称查询
If Check1(0).Value = 1 And Not IsNull(Text1(0).Text) Then
SQLadd = SQLadd + " and Love='" + Text1(0).Text + "'"
End If
'判断QQ查询
If Check1(1).Value = 1 And Not IsNull(Text1(1).Text) Then
SQLadd = SQLadd + " and Oicq='" + Text1(1).Text + "'"
End If
'判断姓名查询
If Check1(2).Value = 1 And Not IsNull(Text1(2).Text) Then
SQLadd = SQLadd + " and Name='" + Text1(2).Text + "'"
End If
'性别查询
If Check1(3).Value = 1 Then
If Option1(0).Value = True Then
SQLadd = SQLadd + " and Sex='" + "男" + "'"
Else
SQLadd = SQLadd + " and Sex='" + "女" + "'"
End If
End If
'年龄查询
If Check1(4).Value = 1 Then
If Check2(0).Value = 1 And IsNumeric(Text2(0).Text) Then
If Check2(1).Value = 1 Then
SQLadd = SQLadd + " and Age<=" + Text2(1).Text
SQLadd = SQLadd + " and Age>=" + Text2(0).Text
Else
SQLadd = SQLadd + " and Age>=" + Text2(0).Text
End If
Else
If Check2(1).Value = 1 Then
SQLadd = SQLadd + " and Age<=" + Text2(1).Text
End If
End If
End If
'判断电话查询
If Check1(5).Value = 1 And Not IsNull(Text1(5).Text) Then
SQLadd = SQLadd + " and TelepNo='" + Text1(5).Text + "'"
End If
'判断手机查询
If Check1(6).Value = 1 And Not IsNull(Text1(6).Text) Then
SQLadd = SQLadd + " and MoveCall='" + Text1(6).Text + "'"
End If
'判断宅电查询
If Check1(7).Value = 1 And Not IsNull(Text1(7).Text) Then
SQLadd = SQLadd + " and Home='" + Text1(7).Text + "'"
End If
'判断传呼查询
If Check1(8).Value = 1 And Not IsNull(Text1(8).Text) Then
SQLadd = SQLadd + " and Call='" + Text1(8).Text + "'"
End If
'判断传真查询
If Check1(9).Value = 1 And Not IsNull(Text1(9).Text) Then
SQLadd = SQLadd + " and Fax='" + Text1(9).Text + "'"
End If
'判断Email查询
If Check1(10).Value = 1 And Not IsNull(Text1(10).Text) Then
SQLadd = SQLadd + " and Email='" + Text1(10).Text + "'"
End If
'更新数据库显示信息
frmData.Data1.DatabaseName = frmData.mdbFile
frmData.Data1.RecordSource = SQLoriginal + SQLadd + SQLorder
frmData.Data1.Refresh
ListRefresh
Unload Me
Exit Sub
ErrHandle:
MsgBox Err.Description
Unload Me
Exit Sub
End Sub
Private Sub Command3_Click() '取消查询
Unload Me
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 0 To 10
'在不处于查询状态时,把文本框设置为失效
Text1(i).Text = ""
Text1(i).Enabled = False
Next i
Option1(0).Enabled = Check1(3).Value
Option1(1).Enabled = Check1(3).Value
'判断年龄输入是否有效
Frame2.Enabled = Check1(4).Value
For i = 0 To 1
Check2(i).Enabled = False
Next i
End Sub
Private Sub Check2_Click(Index As Integer)
Text2(Index).Enabled = Check2(Index).Value
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -