📄 frmquerycontract.frm
字号:
VERSION 5.00
Begin VB.Form frmQueryContract
Caption = "合同查询"
ClientHeight = 4470
ClientLeft = 60
ClientTop = 345
ClientWidth = 8355
LinkTopic = "Form1"
ScaleHeight = 4470
ScaleWidth = 8355
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Caption = "请输入查询条件"
Height = 3375
Left = 240
TabIndex = 13
Top = 120
Width = 7815
Begin VB.ComboBox Combo1
Height = 300
Index = 0
ItemData = "frmQueryContract.frx":0000
Left = 600
List = "frmQueryContract.frx":0022
TabIndex = 0
Text = "Combo1"
Top = 720
Width = 1095
End
Begin VB.TextBox Text1
Height = 375
Index = 0
Left = 3360
TabIndex = 2
Top = 720
Width = 2775
End
Begin VB.ComboBox Combo1
Height = 300
Index = 1
ItemData = "frmQueryContract.frx":007E
Left = 2040
List = "frmQueryContract.frx":008B
TabIndex = 1
Text = "Combo1"
Top = 720
Width = 1095
End
Begin VB.ComboBox Combo1
Height = 300
Index = 2
ItemData = "frmQueryContract.frx":0098
Left = 6360
List = "frmQueryContract.frx":00A5
TabIndex = 3
Text = "Combo1"
Top = 720
Width = 1095
End
Begin VB.ComboBox Combo1
Height = 300
Index = 3
ItemData = "frmQueryContract.frx":00B7
Left = 600
List = "frmQueryContract.frx":00D9
TabIndex = 4
Text = "Combo1"
Top = 1680
Width = 1095
End
Begin VB.ComboBox Combo1
Height = 300
Index = 4
ItemData = "frmQueryContract.frx":0135
Left = 2040
List = "frmQueryContract.frx":0142
TabIndex = 5
Text = "Combo1"
Top = 1680
Width = 1095
End
Begin VB.ComboBox Combo1
Height = 300
Index = 5
ItemData = "frmQueryContract.frx":014F
Left = 6360
List = "frmQueryContract.frx":015C
TabIndex = 7
Text = "Combo1"
Top = 1680
Width = 1095
End
Begin VB.ComboBox Combo1
Height = 300
Index = 6
ItemData = "frmQueryContract.frx":016E
Left = 600
List = "frmQueryContract.frx":0190
TabIndex = 8
Text = "Combo1"
Top = 2640
Width = 1095
End
Begin VB.ComboBox Combo1
Height = 300
Index = 7
ItemData = "frmQueryContract.frx":01EC
Left = 2040
List = "frmQueryContract.frx":01F9
TabIndex = 9
Text = "Combo1"
Top = 2640
Width = 1095
End
Begin VB.ComboBox Combo1
Height = 300
Index = 8
ItemData = "frmQueryContract.frx":0206
Left = 6360
List = "frmQueryContract.frx":0213
TabIndex = 11
Text = "Combo1"
Top = 2640
Width = 1095
End
Begin VB.TextBox Text1
Height = 375
Index = 1
Left = 3360
TabIndex = 6
Top = 1680
Width = 2775
End
Begin VB.TextBox Text1
Height = 375
Index = 2
Left = 3360
TabIndex = 10
Top = 2640
Width = 2775
End
Begin VB.Label Label1
Caption = "查找字段"
Height = 255
Left = 720
TabIndex = 26
Top = 360
Width = 855
End
Begin VB.Label Label2
Caption = "查找值"
Height = 255
Left = 4560
TabIndex = 25
Top = 360
Width = 615
End
Begin VB.Label Label3
Caption = "逻辑关系"
Height = 255
Left = 6480
TabIndex = 24
Top = 360
Width = 735
End
Begin VB.Label Label4
Caption = "查找字段"
Height = 255
Left = 720
TabIndex = 23
Top = 1320
Width = 855
End
Begin VB.Label Label5
Caption = "查找值"
Height = 255
Left = 4560
TabIndex = 22
Top = 1320
Width = 615
End
Begin VB.Label Label6
Caption = "逻辑关系"
Height = 255
Left = 6480
TabIndex = 21
Top = 1320
Width = 735
End
Begin VB.Label Label7
Caption = "查找字段"
Height = 255
Left = 720
TabIndex = 20
Top = 2280
Width = 855
End
Begin VB.Label Label8
Caption = "查找值"
Height = 255
Left = 4560
TabIndex = 19
Top = 2280
Width = 615
End
Begin VB.Label Label9
Caption = "逻辑关系"
Height = 255
Left = 6480
TabIndex = 18
Top = 2280
Width = 735
End
Begin VB.Label Label10
Caption = "查找关系"
Height = 255
Left = 2160
TabIndex = 17
Top = 360
Width = 855
End
Begin VB.Label Label11
Caption = "查找关系"
Height = 255
Left = 2160
TabIndex = 16
Top = 1320
Width = 855
End
Begin VB.Label Label12
Caption = "查找关系"
Height = 255
Left = 2160
TabIndex = 15
Top = 2280
Width = 855
End
End
Begin VB.CommandButton cmdQuery
Caption = "查 询"
Height = 495
Left = 1800
TabIndex = 12
Top = 3720
Width = 1575
End
Begin VB.CommandButton cmdClose
Caption = "关 闭"
Height = 495
Left = 4560
TabIndex = 14
Top = 3720
Width = 1575
End
End
Attribute VB_Name = "frmQueryContract"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdQuery_Click()
'要求至少要有一个查询条件,而且查询条件要靠前写,即如果只有一个查询条件
'必须输在第一行,有2个查询条件,只能输在1,2两行上
If Text1(0).Text = "" Then
MsgBox "请输入至少一个查询条件,或把查询条件输入在前面的行上!", vbOKOnly + vbInformation, "注意"
Text1(0).SetFocus
Text1(1).Text = ""
Text1(2).Text = ""
Exit Sub
End If
If Text1(1).Text = "" And Not Text1(2).Text = "" Then
MsgBox "请把查询条件输入在前面的行上!", vbOKOnly + vbInformation, "注意"
Text1(1).SetFocus
Text1(2).Text = ""
Exit Sub
End If
'合同编号、客户姓名和房屋编号3个查询字段其查询关系不能为> 或 <,判断之
'由于窗体上的控件使用的是数组,因此可以用下面的for循环节省代码
For i = 0 To 2
If Not Text1(i).Text = "" And (Combo1(3 * i).ListIndex = 0 Or Combo1(3 * i).ListIndex = 1 Or Combo1(3 * i).ListIndex = 2) And Not Combo1(3 * i + 1).ListIndex = 0 Then
MsgBox "该字段的查找关系不能为 > 或 < !", vbOKOnly + vbInformation, "注意"
Combo1(3 * i + 1).SetFocus
Exit Sub
End If
Next i
'设置查询判断变量为真
querycon = True
'使用全局变量sqlqcon保存该查询表达式的sql 语句
'如果查询字段是数字型,则需要用Val函数转换text1.text的内容
'如果查询字段是日期型,则需要用dateValue函数转换text1.text的内容,并在两则加上#
For j = 0 To 2
'现判断该text框是否为空
If Not Text1(j).Text = "" Then
'判断该查询字段是否为面积和价位等数字型
'combo1(3*j)为查询字段
If Combo1(3 * j).ListIndex = 0 Or Combo1(3 * j).ListIndex = 1 Or Combo1(3 * j).ListIndex = 2 Then
'判断是否是第一个查询条件,只有第一个查询条件最前面需要用where
If j = 0 Then
'combo1(3*j+1) 为查询关系
sqlqcon = " where " & Combo1(3 * j).Text & Combo1(3 * j + 1).Text & "'" & Text1(j).Text & "'"
Else
'Combo1(3 * j - 1)为逻辑关系
sqlqcon = sqlqcon & " " & Combo1(3 * j - 1).Text & " " & Combo1(3 * j).Text & Combo1(3 * j + 1) & "'" & Text1(j).Text & "'"
End If
'查询字段为日期型
ElseIf Combo1(3 * j).ListIndex = 3 Or Combo1(3 * j).ListIndex = 4 Or Combo1(3 * j).ListIndex = 5 Then
'判断输入的是否为日期型
If IsDate(Text1(j).Text) = False Then
MsgBox "输入的非日期型内容,请输入如下格式的日期:2003-8-5!", vbOKOnly + vbInformation, "注意"
Text1(j).Text = ""
Text1(j).SetFocus
Exit Sub
End If
'判断是否是第一个查询条件,只有第一个查询条件最前面需要用where
If j = 0 Then
'combo1(3*j+1) 为查询关系
sqlqcon = " where " & Combo1(3 * j).Text & Combo1(3 * j + 1).Text & " #" & DateValue(Text1(j).Text) & "#"
Else
'Combo1(3 * j - 1)为逻辑关系
sqlqcon = sqlqcon & " " & Combo1(3 * j - 1).Text & " " & Combo1(3 * j).Text & Combo1(3 * j + 1) & " #" & DateValue(Text1(j).Text) & "#"
End If
'查询字段为数字型,需要在使用val函数
Else
If j = 0 Then
sqlqcon = " where " & Combo1(3 * j).Text & Combo1(3 * j + 1).Text & Val(Text1(j).Text)
Else
sqlqcon = sqlqcon & " " & Combo1(3 * j - 1).Text & " " & Combo1(3 * j).Text & Combo1(3 * j + 1) & Val(Text1(j).Text)
End If
End If
End If
Next j
frmAdminContract.Show
Unload Me
End Sub
Private Sub Form_Load()
'让窗体居中
Dim X0 As Long
Dim Y0 As Long
X0 = Screen.Width
Y0 = Screen.Height
X0 = (X0 - Me.Width) / 2
Y0 = (Y0 - Me.Height) / 2
Me.Move X0, Y0
'设置缺省值
For i = 0 To 8
Combo1(i).ListIndex = 0
Next i
Text1(0).Text = ""
Text1(1).Text = ""
Text1(2).Text = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -