欢迎来到天天文库
浏览记录
ID:61496946
大小:159.00 KB
页数:7页
时间:2021-02-06
《ArcGIS中VBA编写属性查询代码.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、ArcGIS中VBA编写属性查询代码1-1功能说明:图1-1中。第一个组合框用于确定当前图层,第二个确定该图层中的要素属性。利用<>=控制查询范围,text中输入的是:比如查询“面积”>5000的图斑,按“>”,text中就输入5000。结果如下操作方法:窗体创建1,打开tools》macros》visualbasiceditor2,在visualbasiceditor页面,点击insert》userform,添加了一个窗体进来,可以放在nomal里也可以放在“工程”里。然后添加要素,大概如上。双击后键入代码:DimxAsString‘x是用来
2、确定><=的DimiAsInteger‘i进行循环控制PrivateSubCommandButton1_Click()x="<"EndSubPrivateSubCommandButton2_Click()x="="EndSubPrivateSubCommandButton3_Click()x=">"EndSubPrivateSubComboBox1_dropbuttonclick()DimpdocAsIMxDocumentSetpdoc=ThisDocumentDimpmapAsIMapSetpmap=pdoc.FocusMapDimplaye
3、rAsILayerFori=0Topmap.LayerCount-1UserForm1.ComboBox1.AddItempmap.Layer(i).NameNextEndSubPrivateSubComboBox1_Change()DimpdocAsIMxDocumentSetpdoc=ThisDocumentDimpmapAsIMapSetpmap=pdoc.FocusMapDimplayerAsIFeatureLayerFori=0Topmap.LayerCount-1IfComboBox1.Text=pmap.Layer(i).Name
4、ThenSetplayer=pmap.Layer(i)ExitForEndIfNextDimpfclassAsIFeatureClassSetpfclass=player.FeatureClassDimpfieldsAsIFieldsSetpfields=pfclass.FieldsDimpfieldAsIFieldFori=0Topfields.FieldCount-1Setpfield=pfields.Field(i)UserForm1.ComboBox2.AddItempfield.NameNextEndSubPrivateSubComm
5、andButton4_Click()OnErrorGoTolineDimpdocAsIMxDocumentSetpdoc=ThisDocumentDimpmapAsIMapSetpmap=pdoc.FocusMapDimpFeLayerAsIFeatureLayerFori=0Topmap.LayerCount-1Ifpmap.Layer(i).Name=UserForm1.ComboBox1.TextThenSetpFeLayer=pmap.Layer(i)ExitForEndIfNextiDimpFeClassAsIFeatureClass
6、DimpFeCursorAsIFeatureCursorDimpqfilterAsIQueryFilterSetpFeClass=pFeLayer.FeatureClassSetpqfilter=NewQueryFilterpqfilter.WhereClause=ComboBox2.Text+x+TextBox1.TextSetpFeCursor=pFeClass.Search(pqfilter,False)DimpFeatureAsIFeatureFori=0TopFeClass.FeatureCount(pqfilter)-1SetpFe
7、ature=pFeCursor.NextFeaturepmap.SelectFeaturepFeLayer,pFeatureNextiIfpFeClass.FeatureCount(pqfilter)=0ThenMsgBox"没有满足查询条件的地方"EndIfpdoc.ActiveView.RefreshUnloadMeExitSubline:MsgBox"操作错误"EndSubPrivateSubCommandButton5_Click()EndEndSub
此文档下载收益归作者所有