📄 房产资料查询.frm
字号:
End
Begin VB.Label Label10
Caption = "查找关系"
Height = 255
Left = 2160
TabIndex = 18
Top = 360
Width = 855
End
Begin VB.Label Label11
Caption = "查找关系"
Height = 255
Left = 2160
TabIndex = 17
Top = 1320
Width = 855
End
Begin VB.Label Label12
Caption = "查找关系"
Height = 255
Left = 2160
TabIndex = 16
Top = 2280
Width = 855
End
End
Begin VB.CommandButton cmdQueryOne
Caption = "查找后逐个显示"
Height = 495
Left = 1080
TabIndex = 12
Top = 3960
Width = 1575
End
Begin VB.CommandButton cmdClose
Caption = "关 闭"
Height = 495
Left = 5880
TabIndex = 15
Top = 3960
Width = 1575
End
Begin VB.CommandButton cmdQueryTable
Caption = "查找后表格显示"
Height = 465
Left = 3480
TabIndex = 13
Top = 3960
Width = 1575
End
End
Attribute VB_Name = "frmQueryHouse"
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 cmdQueryOne_Click()
'要求至少要有一个查询条件,而且查询条件要靠前写,即如果只有一个查询条件
'必须输在第一行,有2个查询条件,只能输在1,2两行上
If Text1.Text = "" Then
MsgBox "请输入至少一个查询条件,或把查询条件输入在前面的行上!", vbOKOnly + vbInformation, "注意"
Text1.SetFocus
Text2.Text = ""
Text3.Text = ""
Exit Sub
End If
If Text2.Text = "" And Not Text3.Text = "" Then
MsgBox "请把查询条件输入在前面的行上!", vbOKOnly + vbInformation, "注意"
Text2.SetFocus
Text3.Text = ""
Exit Sub
End If
'除使用面积和单价总价以外的查询字段其查询关系不能为> 或 <,判断之
If Not Text1.Text = "" And Not Combo1.ListIndex = 3 And Not Combo1.ListIndex = 5 And Not Combo1.ListIndex = 6 And Not Combo2.ListIndex = 0 Then
MsgBox "该字段的查找关系不能为 > 或 < !", vbOKOnly + vbInformation, "注意"
Combo2.SetFocus
Exit Sub
End If
If Not Text2.Text = "" And Not Combo4.ListIndex = 3 And Not Combo4.ListIndex = 5 And Not Combo4.ListIndex = 6 And Not Combo5.ListIndex = 0 Then
MsgBox "该字段的查找关系不能为 > 或 < !", vbOKOnly + vbInformation, "注意"
Combo5.SetFocus
Exit Sub
End If
If Not Text3.Text = "" And Not Combo7.ListIndex = 3 And Not Combo7.ListIndex = 5 And Not Combo7.ListIndex = 6 And Not Combo8.ListIndex = 0 Then
MsgBox "该字段的查找关系不能为 > 或 < !", vbOKOnly + vbInformation, "注意"
Combo8.SetFocus
Exit Sub
End If
'设置查询判断变量为真
queryhouse = True
'使用全局变量sqlqh保存该查询表达式的sql 语句
'如果查询字段是使用面积和单价总价,则需要转换text1.text的内容
If Combo1.ListIndex = 3 Or Combo1.ListIndex = 5 Or Combo1.ListIndex = 6 Then
'Val 函数把字符串转换为数字
sqlqh = "where " & Combo1.Text & Combo2.Text & Val(Text1.Text)
Else
sqlqh = "where " & Combo1.Text & Combo2.Text & "'" & Text1.Text & "'"
End If
If Not Text2.Text = "" Then
If Combo4.ListIndex = 3 Or Combo1.ListIndex = 5 Or Combo1.ListIndex = 6 Then
'combo3.text是and or not 等逻辑字符,其前后需要各加上一个空格
sqlqh = sqlqh & " " & Combo3.Text & " " & Combo4.Text & Combo5.Text & Val(Text2.Text)
Else
sqlqh = sqlqh & " " & Combo3.Text & " " & Combo4.Text & Combo5.Text & "'" & Text2.Text & "'"
End If
End If
If Not Text3.Text = "" Then
If Combo7.ListIndex = 3 Or Combo1.ListIndex = 5 Or Combo1.ListIndex = 6 Then
sqlqh = sqlqh & " " & Combo6.Text & " " & Combo7.Text & Combo8.Text & Val(Text3.Text)
Else
sqlqh = sqlqh & " " & Combo6.Text & " " & Combo7.Text & Combo8.Text & "'" & Text3.Text & "'"
End If
End If
frmHouse.Show
Unload Me
End Sub
Private Sub cmdQueryTable_Click()
'要求至少要有一个查询条件,而且查询条件要靠前写,即如果只有一个查询条件
'必须输在第一行,有2个查询条件,只能输在1,2两行上
If Text1.Text = "" Then
MsgBox "请输入至少一个查询条件,或把查询条件输入在前面的行上!", vbOKOnly + vbInformation, "注意"
Text1.SetFocus
Text2.Text = ""
Text3.Text = ""
Exit Sub
End If
If Text2.Text = "" And Not Text3.Text = "" Then
MsgBox "请把查询条件输入在前面的行上!", vbOKOnly + vbInformation, "注意"
Text2.SetFocus
Text3.Text = ""
Exit Sub
End If
'除使用面积和单价总价以外的查询字段其查询关系不能为> 或 <,判断之
If Not Text1.Text = "" And Not Combo1.ListIndex = 3 And Not Combo1.ListIndex = 5 And Not Combo1.ListIndex = 6 And Not Combo2.ListIndex = 0 Then
MsgBox "该字段的查找关系不能为 > 或 < !", vbOKOnly + vbInformation, "注意"
Combo2.SetFocus
Exit Sub
End If
If Not Text2.Text = "" And Not Combo4.ListIndex = 3 And Not Combo4.ListIndex = 5 And Not Combo4.ListIndex = 6 And Not Combo5.ListIndex = 0 Then
MsgBox "该字段的查找关系不能为 > 或 < !", vbOKOnly + vbInformation, "注意"
Combo5.SetFocus
Exit Sub
End If
If Not Text3.Text = "" And Not Combo7.ListIndex = 3 And Not Combo7.ListIndex = 5 And Not Combo7.ListIndex = 6 And Not Combo8.ListIndex = 0 Then
MsgBox "该字段的查找关系不能为 > 或 < !", vbOKOnly + vbInformation, "注意"
Combo8.SetFocus
Exit Sub
End If
'设置查询判断变量为真
queryhouse = True
'使用全局变量sqlqh保存该查询表达式的sql 语句
'如果查询字段是使用面积和单价总价,则需要转换text1.text的内容
If Combo1.ListIndex = 3 Or Combo1.ListIndex = 5 Or Combo1.ListIndex = 6 Then
'Val 函数把字符串转换为数字
sqlqh = "where " & Combo1.Text & Combo2.Text & Val(Text1.Text)
Else
sqlqh = "where " & Combo1.Text & Combo2.Text & "'" & Text1.Text & "'"
End If
If Not Text2.Text = "" Then
If Combo4.ListIndex = 3 Or Combo1.ListIndex = 5 Or Combo1.ListIndex = 6 Then
'combo3.text是and or not 等逻辑字符,其前后需要各加上一个空格
sqlqh = sqlqh & " " & Combo3.Text & " " & Combo4.Text & Combo5.Text & Val(Text2.Text)
Else
sqlqh = sqlqh & " " & Combo3.Text & " " & Combo4.Text & Combo5.Text & "'" & Text2.Text & "'"
End If
End If
If Not Text3.Text = "" Then
If Combo7.ListIndex = 3 Or Combo1.ListIndex = 5 Or Combo1.ListIndex = 6 Then
sqlqh = sqlqh & " " & Combo6.Text & " " & Combo7.Text & Combo8.Text & Val(Text3.Text)
Else
sqlqh = sqlqh & " " & Combo6.Text & " " & Combo7.Text & Combo8.Text & "'" & Text3.Text & "'"
End If
End If
frmTableHouse.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
Combo1.ListIndex = 0
Combo2.ListIndex = 0
Combo3.ListIndex = 0
Combo4.ListIndex = 0
Combo5.ListIndex = 0
Combo6.ListIndex = 0
Combo7.ListIndex = 0
Combo8.ListIndex = 0
Combo9.ListIndex = 0
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -