mo+vb程序设计报告Word格式文档下载.docx
《mo+vb程序设计报告Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《mo+vb程序设计报告Word格式文档下载.docx(19页珍藏版)》请在冰点文库上搜索。
1.4实现如下界面功能:
功能解析:
1.4.1能够通过点击条件组合得到查询条件,基于MO提供的空间关系进行查询,并显示查询结果;
1.4.2能够根据查询结果得到属性表,并显示查询结果;
1.4.3根据查询出来的结果进行空间定位与显示。
2、实验目的:
学会使用SearchExpression方法,能利用这种方法进行条件查询,并能将查询结果进行显示,能根据查询记录定位、显示地理要素。
3、设计实验相关情况介绍(包含使用软件以及实验设备等):
(1)使用软件:
MO软件和VB软件
(2)实验设备:
计算机、Windows7系统、键盘、鼠标等。
4、实验过程、方法步骤:
4.1设计软件界面
首先新建一个查询窗体,并设计其界面
然后添加一个窗体,在添加一个按钮,作为空间查询点击的入口按钮
4.2进行编程并进行调试
4.2.1在主窗体中点击“条件查询”,显示条件查询窗体
代码如下:
PrivateSubCommand1_Click()
Form1.Show
EndSub
4.2.2使地图的各图层的名在下拉菜单combo1中显示,并使下拉菜单字段名在list1中显示,即得到如下结果的功能
'
使地图的各图层的名在下拉菜单combo1中显示
PrivateSubForm_Load()
DimplyrAsNewMapObjects2.MapLayer
ForEachplyrInForm2.Map1.Layers
Combo1.AddItemplyr.Name
Nextplyr
Combo1.ListIndex=0
Text1.Text="
"
使下拉菜单字段名在list1中显示
PrivateSubCombo1_Click()
Setlyr=Form2.Map1.Layers(Combo1.ListIndex)
Setprecord=lyr.Records
DimptableAsNewMapObjects2.TableDesc
Setptable=precord.TableDesc
list1.Clear
DimiAsInteger
Fori=0Toptable.FieldCount-1
list1.AddItemptable.FieldName(i)
Nexti
4.2.3在list1中点击属性,在list2显示属性值,即得到如下结果的功能
在list1中点击属性,在list2显示属性值
PrivateSublist1_Click()
DimpfldnameAsString
pfldname=list1.List(list1.ListIndex)
list2.Clear
precord.MoveFirst
WhileNotprecord.EOF
list2.AddItemprecord.Fields(pfldname).ValueAsString
precord.MoveNext
Wend
4.2.4在text1中获得查询条件(即双击list1字段名,双击list2字段名,然后在text1中显示,单击表达式构造符号按钮在text1中显示),即得到如下结果的功能
双击list1字段名,在text中显示
PrivateSublist1_DblClick()
Text1.Text=Text1.Text+list1.List(list1.ListIndex)
双击list2字段名,在text中显示
PrivateSublist2_DblClick()
Text1.Text=Text1.Text+list2.List(list2.ListIndex)
单击各个符号在text1中进行显示
PrivateSubCommand5_Click()
Text1.Text=Text1.Text+Command5.Caption
PrivateSubCommand6_Click()
Text1.Text=Text1.Text+Command5.caption
PrivateSubCommand7_Click()
Text1.Text=Text1.Text+"
and"
PrivateSubCommand8_Click()
Text1.Text=Text1.Text+Command8.caption
PrivateSubCommand9_Click()
Text1.Text=Text1.Text+Command9.caption
PrivateSubCommand10_Click()
or"
PrivateSubCommand11_Click()
Text1.Text=Text1.Text+Command11.caption
PrivateSubCommand12_Click()
Text1.Text=Text1.Text+Command12.caption
PrivateSubCommand13_Click()
not"
PrivateSubCommand14_Click()
Text1.Text=Text1.Text+Command14.caption
PrivateSubCommand15_Click()
Text1.Text=Text1.Text+Command15.caption
PrivateSubCommand16_Click()
like"
4.2.5获得查询条件,进行查询并在地图中进行显示以及获得属性表,得到如下结果
PublicrecordAsMapObjects2.Recordset'
定义查询的记录集
PublicponoffAsBoolean'
定义一个开关,(由于在差un提运行时就开始查询,所以要定义开关,在窗体运行时处于关状态,点击查询时才开始查询)
窗体运行时开关处于关状态
ponoff=False
查询及其显示(由于AfterTrackingLayerDraw是Map的方法,所以应该在Map1下进行编辑代码)
PrivateSubMap1_AfterTrackingLayerDraw(ByValhDCAsstdole.OLE_HANDLE)
Ifponoff=TrueThen
Setrecord=Form2.Map1.Layers(Form1.Combo1.ListIndex).SearchExpression(Form1.Text1.Text)
DimpsymAsNewMapObjects2.Symbol
psym.Color=moRed
Form2.Map1.DrawShaperecord,psym
EndIf
点击查询时,属性表的显示
PublicSubDisplaySelFeature()
IfNotrecordIsNothingThen
DimtDescAsMapObjects2.TableDesc
DimiAsInteger
SettDesc=record.TableDesc
DimrecscountAsInteger
'
**********************************************************
'
以下代码用来填充msgflexgrid
DimmAsInteger
DimnAsInteger
record.MoveFirst
DoWhileNotrecord.EOF
record.MoveNext
recscount=recscount+1
Loop
MsgBoxrecsCount
Form1.MSFlexGrid1.Cols=tDesc.FieldCount+1
Form1.MSFlexGrid1.Rows=recscount+1
Form1.MSFlexGrid1.AllowUserResizing=flexResizeColumns
Form1.MSFlexGrid1.Clear
Form1.MSFlexGrid1.CellAlignment=flexAlignLeftCenter
Fori=1TotDesc.FieldCount
Form1.MSFlexGrid1.ColWidth(i)=tDesc.FieldLength(i-1)*72
Nexti
tofilledthefieldsnameintogrid
Form1.MSFlexGrid1.TextMatrix(0,0)="
特征ID"
Fori=1Torecscount
Form1.MSFlexGrid1.TextMatrix(i,0)=i
Fori=0TotDesc.FieldCount-1
Form1.MSFlexGrid1.TextMatrix(0,i+1)=tDesc.FieldName(i)
Form1.MSFlexGrid1.ColAlignment(i)=flexAlignLeftCenter
Form1.MSFlexGrid1.ColWidth(i)=1200
Form1.MSFlexGrid1.ColAlignment(0)=flexAlignCenterCenter
Form1.MSFlexGrid1.ColWidth(0)=680
Form=1Torecscount
Forn=0TotDesc.FieldCount-1
Form1.MSFlexGrid1.TextMatrix(m,n+1)=record.Fields(tDesc.FieldName(n)).Value
Nextn
Next
Form1.MSFlexGrid1.Refresh
EndIf
点击查询按钮进行查询(实际查询过程在Map1_AfterTrackingLayerDraw过程中,这里点击查询按钮,用开关进行控制查询)
ponoff=True
Form2.Map1.Refresh
DisplaySelFeature
4.2.6清除功能的实现,点击清除功能,对text1以及属性表MSFlexGrid1中的条件进行清除
清除功能:
PrivateSubCommand2_Click()
"
Form1.MSFlexGrid1.Clear
Setrecord=Nothing
Form2.Map1.Refresh
4.2.7闪烁功能的实现,对选择出来的结果进行闪烁
进行闪烁
PrivateSubCommand3_Click()
Form2.Map1.FlashShaperecord("
shape"
).Value,3
4.2.8居中共能的实现,即对选中的结果进行居中显示
进行居中显示
PrivateSubCommand4_Click()
DimRectAsRectangle,Rect2AsRectangle
DimshapeXAsDouble,shapeYAsDouble
DimdeltaxAsDouble,deltayAsDouble
DimtheShapeAsObject,pinPointAsMapObjects2.Point
DimrecNoAsInteger
recNo=MSFlexGrid1.Row-1
记录指针移动到属性数据表选择中的记录上
Fori=0TorecNo-1
SettheShape=record("
).Value
Ifrecord("
).Type=moPointThen
SetRect2=Form2.Map1.Extent
shapeX=record("
).Value.X
shapeY=record("
).Value.Y
deltax=shapeX-Rect2.Center.X
deltay=shapeY-Rect2.Center.Y
Rect2.Offsetdeltax,deltay
Rect2.ScaleRectangle0.1
Form2.Map1.Extent=Rect2
Else
SetRect=record("
).Value.Extent
Rect.ScaleRectangle1.1
Form2.Map1.Extent=Rect
SetRect2=Nothing
SettheShape=Nothing
5、实验结果:
5.1查询功能运行的结果
面查询:
线查询:
点查询:
5.2清除功能的实现
查询:
然后再清除:
5.3闪烁功能的实现
先查询
后闪烁
5.4居中功能的实现
后居中
6、实验小结(出现过的问题或错误、原因分析):
6.1在实验过程中,对VB编程的不熟悉,导致速度很慢。
6.2在实验过程中,由于对很对函数的作用不了解,很多时候需要查看帮助。
6.3在实验过程中,出现多次语法等错误导致结果出不来。
还得需要老师的帮助或看老师的代码才能解决问题,自主编程能力差,还需要多家练习。
6.4功能不完善,在进行调试的时候,出现很多问题和漏洞还不能解决。
指导老师评语:
指导老师签名:
2013年月日