DOC PREVIEW
USA GY 461 - GIS and Programming with Visual Basic

This preview shows page 1-2-3-4 out of 13 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

GIS and Programming with GIS and Programming with Visual BasicVisual BasicExample: Trend Surface Example: Trend Surface Analysis of a Subsurface Analysis of a Subsurface Petroleum ReservoirPetroleum ReservoirVisual Basic EditorVisual Basic EditorEditor is invoked by creating a Editor is invoked by creating a ““macromacro””from within Excelfrom within Excel““ToolsTools””> > ““MacroMacro””> > ““Record New Record New MacroMacro””Simply move the cursor to generate Simply move the cursor to generate code and then stop recordingcode and then stop recordingUse Use ““ToolsTools””> > ““MacroMacro””> > ““Visual Visual Basic EditorBasic Editor””to enter VB editorto enter VB editorExample of Visual Basic EditorExample of Visual Basic EditorNote Note that that ““ctrl+qctrl+q””activates activates the the macromacroVisual Basic ConceptsVisual Basic ConceptsConstants: literal valuesConstants: literal values––Integer: 2Integer: 2––Single, Double precision: 3.1416Single, Double precision: 3.1416––String: String: ““Trend SurfaceTrend Surface””Variables: a symbolic alphanumeric Variables: a symbolic alphanumeric name that stores a valuename that stores a valueVisual Basic Concepts: Visual Basic Concepts: DeclarationsDeclarationsDeclarations classify variablesDeclarations classify variables––Dim x, y, z as singleDim x, y, z as single––Dim Dim strvarstrvaras stringas string––Dim i, j as integerDim i, j as integerBy convention variables that begin By convention variables that begin with with ii--nnare declared as integer but are declared as integer but that is not enforced by VBthat is not enforced by VBTo avoid errors all variables used by To avoid errors all variables used by a macro should be declareda macro should be declaredVisual Basic Declarations ExampleVisual Basic Declarations ExampleInteger, DoubleInteger, Double--precision and string precision and string variables are declared for use in the variables are declared for use in the macromacroVisual Basic: Assignment Visual Basic: Assignment StatementsStatementsAssignment statements are made with the Assignment statements are made with the ““==““symbol. This stores the value to the symbol. This stores the value to the right of the right of the ““==““into the variable to the left into the variable to the left of the of the ““==““..Visual Basic OperatorsVisual Basic OperatorsMost operators are Most operators are ““numericnumeric””––they they operate on numbers to process operate on numbers to process calculations:calculations:––““++””additionaddition––““--””subtractionsubtraction––““**””multiplicationmultiplication––““//””divisiondivision––““^^””or or ““****””exponentiationexponentiationExamples:Examples:––xrangexrange= = xurxur––xllxll––Area = x^2Area = x^2Application of StatementsApplication of StatementsVisual Basic StatementsVisual Basic StatementsFor loop: processes one or more For loop: processes one or more statements for a set number of cyclesstatements for a set number of cyclesVisual Basic: UserVisual Basic: User--defined defined FunctionsFunctionsMany intrinsic functions exist in Many intrinsic functions exist in programming languages such programming languages such asVBasVB::––X = X = Cos(yCos(y))A function takes an argument and returns A function takes an argument and returns a calculated value such as the cosine of an a calculated value such as the cosine of an angleangleUserUser--defined (explicit) functions are defined (explicit) functions are written by the user:written by the user:––X = X = MyFunc(yMyFunc(y))––The function The function ““MyFuncMyFunc””must be written by the must be written by the programmer (i.e. it is not part of standard VB)programmer (i.e. it is not part of standard VB)Visual Basic: FunctionsVisual Basic: FunctionsProgramming NotesProgramming NotesThe example used in this presentation was The example used in this presentation was for a 1for a 1ststorder trend surfaceorder trend surface--the the assignment will use a 3assignment will use a 3rdrdorder trend order trend surfacesurfaceTo start a VB macro program use the To start a VB macro program use the Ctrl+{keyCtrl+{key} that you assigned to the } that you assigned to the macromacroIf you have errors the VB system will If you have errors the VB system will usually mark the line where the error usually mark the line where the error


View Full Document

USA GY 461 - GIS and Programming with Visual Basic

Download GIS and Programming with Visual Basic
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view GIS and Programming with Visual Basic and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view GIS and Programming with Visual Basic 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?