Working with Visual Basic

 

Working with the interfaces from a Visual Basic (VB) environment is similar to using the VB scripting language explained above. Visual Basic provides a stronger programming environment, and user interface management.

 

For best performance, create an ActiveX Project, embed it in an HTML page, and open it in one of the TerraExplorer containers.

Running your VB application as a separate application introduces inter-process communication between TerraExplorer and your application, which is less efficient than the in-process communication of the first option.
The instructions provided here refer to Microsoft Visual Basic 6.0.

 

A VB Boolean use -1 for TRUE value and 0 for FALSE value, TerraExplorer uses the same FALSE value but uses 1 for TRUE. This can cause errors when comparing Boolean values returned from TerraExplorer. For example, the value of the expression (FlipTexture = true)

is always false. To avoid this, use a VB CBool Type conversion function

(cbool(FlipTexture) = true)

or, compare value to 0

(FlipTexture <> 0)

 

Follow these steps to create a Visual Basic client application using TerraExplorer Interfaces:

  1. Set Project References – from the Project menu, select References. Select TerraExplorerX 1.0 Type Library from the available references.

  2. Define Variable for TerraExplorer Object – create an object variable to reference to TerraExplorer. Use the WithEvents keyword.

Dim WithEvents TE As TerraExplorer

  1. Create TerraExplorer Object – Use the CreateObject Function to reference the variable to the TerraExplorer object. TerraExplorer uses the application name TerraExplorer2 and object name TerraExplorer. You can also use the New keyword. This can be done in the Form_Load() sub.

Set TE = CreateObject("TerraExplorer2.TerraExplorer")

Or

  Set TE = New TerraExplorer

  1. Declare Variables – Declare variables for the interfaces you intend to use in your application. The variables need to be defined as the TerraExplorer interface they are intended for.

Dim ITerraExplorer As ITerraExplorer4

  1. Assign the Interfaces – Assign the required TerraExplorer interfaces to each variable you declared.

Set ITerraExplorer = TE

  1. Call a Method With a Return Value – When calling a method that returns a value, you must put the method’s parameters in brackets.

ItemID = IInfoTree.GetNextItem(0, 10)

  1. Call a Method With No Return Value – If the method does not return a value, use the call statement.

call ITerraExplorerObject5.SetPosition (100, 100, 200, 0, 0, 0, 56)

  1. Get Property Value – Get = ITerrain3.MPTName

  2. Set Property Value – Set an interface property using the following syntax.

ITerraExplorer4. DisplayErrorMessages = 0

 

 

  1.