GeoCOM Reference Manual
Fundamentals of Programming GeoCOM
Leica TPS1200 / TS30 / TM30 – Version 1.50
14
3.4
VBA - PROGRAMMING
Similar to C/C++ programming the programming of VBA is based on the DLL concept. To enable access to GeoCOM
the special module
COM_StubsPub.bas
has to be included in the project.
COM_StubsPub.bas
includes all constants,
data types and function prototypes, which are available in GeoCOM.
3.4.1
Data Types in VBA - General rules for derivation
This subsection gives a summary of general derivation rules VBA-parameters from C-data types. Basically the C/C++ -
data types are given in a C/C++ notation before they are used in a RPC-description.
If the appearance of a VBA data type does not follow the general rules then they are described explicitly.
In general, the following rules can be applied:
Numerical data type
The numerical data types correspond to the C/C++-parameters in value and range as close as possible. If it
cannot be replaced directly then the best possible replacement will be taken.
String data type
Character and string types are replaced by
string
data types. Since string data types of C/C++ and VBA are not
directly interchangeable, the programmer has to take certain care of the necessary pre- and post-processing of
variables of this data type. Please refer to the example below.
Enumeration data type
Conceptually VBA does not have enumeration data types. Therefore,
Long
data types will be used instead. The
enumeration values will be defined by constants. Using the numerical value is also valid. Notice that some of the
enumeration values are reserved words in VBA. That is why we had to define different identifiers. Enumerated
return values are numerical values and correspond to the position of the enumeration value in the C/C++-
definition. For clarification, also the numerical values are given in the description of an enumeration data type.
Structures and Arrays
They are defined as in C/C++.
Example for Enumeration Data Types and Structures
The following example gives the data type declaration and the procedure declaration usually used in this manual
for an example procedure (
TMC_GetSimpleMea
from the subsystem Theodolite Measurement and Calculation):
VBA-Declaration
VB_TMC_GetSimpleMea(
WaitTime As Long,
OnlyAngle As TMC_HZ_V_ANG,
SlopeDistance As Double,
Mode
As Long)
In the file
COM_StubsPub.bas
the corresponding items are defined:
Global Const TMC_MEA_INC = 0
Global Const TMC_AUTO_INC = 1
Global Const TMC_PLANE_INC = 2
Global Const TMC_APRIORI_INC = 3
Global Const TMC_ADJ_INC = 4
Global Const TMC_REQUIRE_INC = 5
Type TMC_HZ_V_ANG
dHz As Double
dV As Double
End Type
Obviously all enumeration values are encoded as global constants. The VBA structure definition equals to the C
structure definition. A valid procedure call would be:
Dim WaitTime As Long
Dim OnlyAngle As TMC_HZ_V_ANG
Dim SlopeDistance As Double
WaitTime = 1000
VB_TMC_GetSimpleMea( WaitTime,