📄 checkgraphy.frm
字号:
VERSION 5.00
Begin VB.Form checkgraphy
Caption = "属性检索"
ClientHeight = 5865
ClientLeft = 60
ClientTop = 450
ClientWidth = 5895
LinkTopic = "Form3"
ScaleHeight = 5865
ScaleWidth = 5895
StartUpPosition = 3 '窗口缺省
Begin VB.ListBox List1
Height = 2040
Left = 120
TabIndex = 22
Top = 1440
Width = 1335
End
Begin VB.ComboBox Combo1
Height = 300
Left = 120
TabIndex = 21
Text = "Combo1"
Top = 960
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 375
Left = 1200
TabIndex = 20
Top = 5280
Width = 1335
End
Begin VB.CheckBox Check1
Caption = "显示字段值"
Height = 255
Left = 4200
TabIndex = 17
Top = 3360
Width = 1455
End
Begin VB.TextBox Text1
Height = 855
Left = 120
TabIndex = 3
Top = 4200
Width = 5535
End
Begin VB.ListBox List2
Height = 2400
Left = 4200
TabIndex = 2
Top = 840
Width = 1455
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 375
Left = 3720
TabIndex = 0
Top = 5280
Width = 1455
End
Begin VB.Frame Frame1
Caption = "运算符"
Height = 3015
Left = 1680
TabIndex = 1
Top = 720
Width = 2295
Begin VB.CommandButton Command3
Caption = "()"
Height = 255
Index = 10
Left = 840
TabIndex = 15
Top = 2520
Width = 615
End
Begin VB.CommandButton Command3
Caption = "[]"
Height = 255
Index = 11
Left = 1560
TabIndex = 14
Top = 2520
Width = 615
End
Begin VB.CommandButton Command3
Caption = ">="
Height = 255
Index = 3
Left = 120
TabIndex = 13
Top = 1080
Width = 615
End
Begin VB.CommandButton Command3
Caption = "<"
Height = 255
Index = 2
Left = 1560
TabIndex = 12
Top = 360
Width = 615
End
Begin VB.CommandButton Command3
Caption = "<="
Height = 255
Index = 4
Left = 840
TabIndex = 11
Top = 1080
Width = 615
End
Begin VB.CommandButton Command3
Caption = "<>"
Height = 255
Index = 5
Left = 1560
TabIndex = 10
Top = 1080
Width = 615
End
Begin VB.CommandButton Command3
Caption = "add"
Height = 255
Index = 6
Left = 120
TabIndex = 9
Top = 1800
Width = 615
End
Begin VB.CommandButton Command3
Caption = "or"
Height = 255
Index = 7
Left = 840
TabIndex = 8
Top = 1800
Width = 615
End
Begin VB.CommandButton Command3
Caption = "like"
Height = 255
Index = 8
Left = 1560
TabIndex = 7
Top = 1800
Width = 615
End
Begin VB.CommandButton Command3
Caption = "in"
Height = 255
Index = 9
Left = 120
TabIndex = 6
Top = 2520
Width = 615
End
Begin VB.CommandButton Command3
Caption = "="
Height = 255
Index = 1
Left = 840
TabIndex = 5
Top = 360
Width = 615
End
Begin VB.CommandButton Command3
Caption = ">"
Height = 255
Index = 0
Left = 120
TabIndex = 4
Top = 360
Width = 615
End
End
Begin VB.Label Label3
Caption = "字段值:"
Height = 255
Left = 4200
TabIndex = 19
Top = 480
Width = 1455
End
Begin VB.Label Label2
Caption = "图层及字段:"
Height = 255
Left = 120
TabIndex = 18
Top = 480
Width = 1335
End
Begin VB.Label Label1
Caption = "查询语法:"
Height = 255
Left = 120
TabIndex = 16
Top = 3840
Width = 1095
End
End
Attribute VB_Name = "checkgraphy"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub layerload()
Dim layer As New MapObjects2.MapLayer '定义一个矢量图层对象
Combo1.clear '将组合框清空
For Each layer In Form1.Map1.Layers '循环所有矢量图层,并将图层名字添加到组合框中
Combo1.AddItem layer.name
Next layer
Combo1.ListIndex = 0
End Sub
Private Sub fieldload(str As String) '将选中图层所包含的属性字段加入list
Dim rec As MapObjects2.Recordset
Dim fld As MapObjects2.field
Set rec = Form1.Map1.Layers(str).Records
List1.clear
For Each fld In rec.Fields
List1.AddItem fld.name
Next fld
Set rec = Nothing
End Sub
Private Sub valueload(str As String) '将选中的字段的值加入list 中
Dim rec As MapObjects2.Recordset
Dim fld As MapObjects2.field
Set rec = Form1.Map1.Layers(Combo1.Text).Records
List2.clear
Do While Not rec.EOF
List2.AddItem rec.Fields(str).ValueAsString
rec.MoveNext
Loop
Set rec = Nothing
End Sub
Private Sub Check1_Click() '对复选框进行判断,并调用相应的子程序
If Check1.Value = 1 Then '包括装载属性字段值、和清除列表框中的值
Dim fld As String
fld = List1.Text
Call valueload(fld)
Else
List2.clear
End If
End Sub
Private Sub Combo1_Click()
Call fieldload(Combo1.Text)
End Sub
Private Sub Command1_Click() '调用模块中的函数,其中包括两个参数(所选图层、SQL查询条件)
Dim str1 As String
Dim str2 As String
str1 = Text1.Text
str2 = Combo1.Text
checkgraphy.Hide
MsgBox "查找区域将闪烁"
Call drawshape(str1, str2)
End Sub
Private Sub Command2_Click() '卸载当前窗体
Unload checkgraphy
End Sub
Private Sub Command3_Click(Index As Integer) '运算符控件组
Select Case Index
Case 0: Text1.Text = Text1.Text & ">"
Case 1: Text1.Text = Text1.Text & "="
Case 2: Text1.Text = Text1.Text & "<"
Case 3: Text1.Text = Text1.Text & ">="
Case 4: Text1.Text = Text1.Text & "<="
Case 5: Text1.Text = Text1.Text & "<>"
Case 6: Text1.Text = Text1.Text & "add"
Case 7: Text1.Text = Text1.Text & "or"
Case 8: Text1.Text = Text1.Text & "like"
End Select
End Sub
Private Sub Form_Load() '调用装载图层函数
layerload
End Sub
Private Sub List1_DblClick()
Text1.Text = " "
Text1.Text = List1.Text '用listindex时只能显示当前的第一个值,要用text
End Sub
Private Sub List2_DblClick()
If IsNumeric(List2.Text) Then '将属性值添加到text控件中,要判断list2中的值,到底是数值还是字符
Text1.Text = Text1.Text & List2.Text
Else
Text1.Text = Text1.Text & "'" & List2.Text & "'" '字符要用单引号括起来
End If
End Sub
Public Sub drawshape(str1 As String, str2 As String) '在trackinglayer图层中展示查询结果
Dim rec As MapObjects2.Recordset
Dim geo As New MapObjects2.GeoEvent
Dim obj As Object
Form1.Map1.TrackingLayer.SymbolCount = 1
With Form1.Map1.TrackingLayer.Symbol(0)
.color = moRed
.Size = 5
End With
Set rec = Form1.Map1.Layers(str2).SearchExpression(str1)
Do While Not rec.EOF
Set obj = rec.Fields("Shape").Value
'Set geo = form1.Map1.TrackingLayer.AddEvent(obj, 0)
Form1.Map1.FlashShape obj, 5
Set obj = Nothing
rec.MoveNext
Loop
Form1.Map1.TrackingLayer.Refresh True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -