arcobjects的开发内容摘要:

ment  创建用户交互窗体( Form) 构建比 message boxes and input boxes更复杂的用户界面 Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 252 Working with forms  Form = window of controls + associated code Form Designer Properties window Toolbox Code module Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 253 Setting properties at design time  Select a control  View or change properties with the Properties window Appearance: Caption, Font, BackColor Behavior: TabIndex, Locked, Enabled NAME Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 255 Writing code for a form  UserForms 由一个设计器和一个代码模块组成  双击一个 control 去展开它的代码 Each control on a form has several event procedures Code Module Form Designer Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 256 Using control properties at run time  Get/Set properties with code while the form is running  Syntax: Controls are objects Private Sub cmdApply_Click() strFTemp = ( * 9 / 5 ) + 32 = Fahrenheit: amp。 strFTemp End Sub Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 257 When: Form and control events  Code runs when an event fires  Different controls have different sets of events Form events Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 259 When: Map document events  Available in the ThisDocument module  Normal, base template, or current map (.mxd)  Event procedures for the MxDocument object Open, close, new, change, etc. Object List Procedure List Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 261 Saving your work  Save modules with a document ArcCatalog normal template ArcMap normal template ArcMap template (*.mxt) Map document (*.mxd)  Export modules Form file (*.frm): designer and code Standard and class modules Can be imported into other projects Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 262 Exercise 3 overview  Create a form  Set initial control properties  Test and debug the form  Work with preset variables Application ThisDocument  Save your work Copyright 169。 2020, 2020 ESRI. All rights reserved. Introduction to Programming ArcObjects with VBA Using variables( III) Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 264 在 VBA中使用变量  变量定义  使用变量 : 申明 , 赋值 , 比较  过程的参数传值和返回值  比较两个变量的值  分支 : 判断语句  变量的作用域 Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 265 Variables  An empty box for storing values Of a specific type (integer, date, string, etc.) The value stored can change 39。 the VB version of: a178。 + b178。 = c178。 , is … dblCSquare = (dblA * dblA) + (dblB * dblB) „转换温度的计算 … intTempCelsius = InputBox (Enter temperature (C): ) intTempFahrenheit = (intTempCelsius * ) + 32 Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 266 Working with variables  Declaring: Create a variable  Setting: Store a value  Evaluating: Get the value MsgBox myDog myDog = Sparky Dim myDog As String myDog Sparky myDog Sparky myDog Sparky A Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 268 Dim (dimension) statement  申明一个变量  指定变量的类型 39。 Declare variables Dim strFilePathName As String Dim datSparkysBirthday As Date Dim intCount As Integer 39。 Other ways to declare variables (to be discussed later).. Private strFilePathName As String Public datSparkysBirthday As Date Static intCount As Integer Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 270 变量赋值  直接赋值或通过返回值赋值 如果是一个功能过程的返回值赋值,使用圆括号 39。 Assign values directly intCount = 23 39。 Assign a function return value strFilePathName = InputBox(File to open: ) 39。 Assign an object property strMapName = ! Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 272 Function procedures  Functions return a value … by assigning a value to the function name Syntax for calling a function: Value = Function ( arguments ) 39。 Call the TotalPrice function Private Sub Purchase() dblPrice = InputBox (Enter price before tax:) dblTotal = TotalPrice(dblPrice) MsgBox Here is the price including tax: amp。 dblTotal End Sub 39。 The function procedure TotalPrice Private Function TotalPrice(Price As Double) As Double TotalPrice = Price * End Function Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 274 比较变量的值  Use relational operators ( , , , = ) Return a Boolean result (true/false)  Functions IsDate IsNumeric IsNull TypeName intAnswer = MsgBox (Delete File?, vbYesNo) MsgBox intAnswer = vbYes MsgBox Number? amp。 IsNumeric(VagueVariable) strType = TypeName (VagueVariable) MsgBox Variable is of data type amp。 strType Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 276 判断语句 : The If Then statement  根据条件分支执行 Use a Boolean expression 作出决定如何执行 If intLayerCount 1 Then MsgBox There are no layers in your map!, vbExclaimation End If 39。 Syntax example: If a condition is true Then 39。 do something... End If ? Introduction to Programming ArcObjects with VBA Copyright 169。 2020。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。