Some Implementation Issues of Scanner Data Muhanad Sammar, Anders Norberg & Can Tongur.
VBA in Arcgis-Muhanad(1)
Transcript of VBA in Arcgis-Muhanad(1)
-
8/15/2019 VBA in Arcgis-Muhanad(1)
1/24
VBA IN ARCGISBy: Muhanad Gaafar Osman
-
8/15/2019 VBA in Arcgis-Muhanad(1)
2/24
What is Visual Basic?
• Is a tool that allows you to develop Windows (Graphic serInterface ! GI" applications# $he applications have a familappearance to the user#
• Is event!driven% meanin& code remains idle until called uporespond to some event ('utton pressin&% menu selection% ##
•
is &overned 'y an event processor# othin& happens until event is detected# Once an event is detected% the codecorrespondin& to that event (event procedure" is e)ecuted#
-
8/15/2019 VBA in Arcgis-Muhanad(1)
3/24
*ome +eatures of Visual Basic
• +ull set of o',ects ! you -draw- the application
• .ots of icons and pictures for your use#
• /esponse to mouse and 0ey'oard actions1
• 2lip'oard and printer access#
• +ull array of mathematical% strin& handlin&% and &raphics functions#
• 2an handle 3)ed and dynamic varia'le and control arrays#
• *e4uential and random access 3le support#
• seful de'u&&er and error!handlin& facilities#
• 5owerful data'ase access tools#
• 6ctive7 support#
• 5ac0a&e 8 9eployment Wiard ma0es distri'utin& your applications simple
-
8/15/2019 VBA in Arcgis-Muhanad(1)
4/24
*tructure of a Visual Basic6pplicationApplication (Project) is made up of:
• Forms ! Windows that you create for user interface#
• Controls ! Graphical features drawn on forms to allow user interaction (te)t 'o)es% l'ars% command 'uttons% etc#" (+orms and 2ontrols are o',ects#"#
• Properties ! ;very characteristic of a form or control is speci3ed 'y a property# ;)aproperties include names% captions% sie% color% position% and contents# Visual Basic adefault properties#
-
8/15/2019 VBA in Arcgis-Muhanad(1)
5/24
*teps in 9evelopin& 6pplicatio
$!ere are t!ree primar% stepsin#ol#ed in &uildin' a Visual Basiapplication:
=# 9raw the user interface#># 6ssi&n properties to controls#
# 6ttach code to controls
-
8/15/2019 VBA in Arcgis-Muhanad(1)
6/24
Varia'les
• Varia'les are used 'y Visual Basic to hold information needyour application# /ules used in namin& varia'les:
• @ o more than A characters
• @ $hey may include letters% num'ers% and underscore (C"
• @ $he 3rst character must 'e a letter
• @
-
8/15/2019 VBA in Arcgis-Muhanad(1)
7/24
Visual Basic 9ata $ypes:
• Boolean
• Inte&er
• .on& (Inte&er"
• *in&le (+loatin&"
• 9ou'le (+loatin&"
• 2urrency• 9ate
• O',ect
• *trin&
• Variant
-
8/15/2019 VBA in Arcgis-Muhanad(1)
8/24
• varia'les are declared usin& the istatement:
•im MyInt as Inte&er•im My9ou'le as 9ou'le
•im My*trin&%
-
8/15/2019 VBA in Arcgis-Muhanad(1)
9/24
Visual Basic *tatements and;)pressions $he simplest statement is the assi&nment statement# Iconsists of a varia'le name% followed 'y the assi&nmenoperator (D"% followed 'y some sort of e)pression#
•"amples:• *tart$ime D ow
• ;)plorer#2aption D E2aptain *pauldin&E• Bit2ount D Byte2ount F
• ;ner&y D Mass F .IGH$*5;;9 >
• etWorth D 6ssets ! .ia'ilities
$he assi&nment statement stores information#
-
8/15/2019 VBA in Arcgis-Muhanad(1)
10/24
Visual Basic Operators $he simplest operators carry out arithmetic operations# $hese operaorder of precedence are:
*perator *peration
;)ponentiation
FJ Multiplication and division
K Inte&er division (truncates"
Mod Modulus
L ! 6ddition and su'utraction
$o concatentate two strin&s% use the 8 sym'ol or the L sym'ol:
l'l$ime#2aption D E$he current time isE 8 +ormat(ow% hh:mmN"
t)t*ample#$e)t D EHoo0 this L to thisN
-
8/15/2019 VBA in Arcgis-Muhanad(1)
11/24
comparison operators $here are si) comparison operators in Visual Basic:
*perator Comparison
Greater than
P .ess than
D Greater than or e4ual
PD .ess than or e4ual to
D ;4ual to
P ot e4ual to
The result of a comparison operation is a Boolean value (True or Fa
-
8/15/2019 VBA in Arcgis-Muhanad(1)
12/24
.o&ical OperatorsWe will use three lo&ical operators
*perator *perationot .o&ical not
6nd .o&ical and
Or .o&ical or
• $he ot operator simply ne&ates an operand#• $he 6nd operator returns a $rue if 'oth operands are $rue# ;lse% it ret
• $he Or operator returns a $rue if either of its operands is $rue% else it +alse#
• .o&ical operators follow arithmetic operators in precedence#
-
8/15/2019 VBA in Arcgis-Muhanad(1)
13/24
If *tatements
• $he simplest is the IfJ$hen statement:
If Balance ! 2hec0 P $hen 5rintE
-
8/15/2019 VBA in Arcgis-Muhanad(1)
14/24
•
-
8/15/2019 VBA in Arcgis-Muhanad(1)
15/24
• Or% we can add the ;lseIf statement:
If Balance ! 2hec0 P $hen
5rint E
-
8/15/2019 VBA in Arcgis-Muhanad(1)
16/24
Visual Basic .oopin&
• .oopin& is done with the o+,oop format# .oops are used operations are to 'e repeated some num'er of times# $he repeats until some speci3ed condition at the 'e&innin& or ethe loop is met#
• 9o WhileJ.oop ;)ample:
2ounter D =
9o While 2ounter PD =
9e'urint 2ounter
2ounter D 2ounter L =
.oop
-
8/15/2019 VBA in Arcgis-Muhanad(1)
17/24
•9o ntilJ.oop ;)ample:
2ounter D =9o ntil 2ounter =
9e'urint 2ounter2ounter D 2ounter L =.oop
-
8/15/2019 VBA in Arcgis-Muhanad(1)
18/24
•9oJ.oop While ;)ample:
*um D =9o
9e'urint *um*um D *um L
.oop While *um PD R
-
8/15/2019 VBA in Arcgis-Muhanad(1)
19/24
•9oJ.oop ntil ;)ample:
*um D =9o
9e'urint *um*um D *um L .oop ntil *um R
-
8/15/2019 VBA in Arcgis-Muhanad(1)
20/24
+orJe)t loop
2ountin& is accomplished usin& the +orJe)t loop#
;)ample
+or I D = to R *tep >
6 D I F >
9e'urint 6
e)t I
-
8/15/2019 VBA in Arcgis-Muhanad(1)
21/24
Pro'rammin' -it! *&jects:
•6rcO',ects is a set of pro&ramma'leo',ects
•Visual Basic 6pplication (VB6" is ano',ect Soriented pro&rammin& lan&uSoriented pro&rammin& lan&ua&e
•VB6 is included with 6rcGI* 9es0top(6rcMap and 6rc2atalo&"1
-
8/15/2019 VBA in Arcgis-Muhanad(1)
22/24
*tartin& the Visual Basi;ditor:
-
8/15/2019 VBA in Arcgis-Muhanad(1)
23/24
;)plorin& the VB6 *ections:
-
8/15/2019 VBA in Arcgis-Muhanad(1)
24/24
6rcO',ectT