MicroStation VBA

LA Solutions staff have written a number of technical articles.
These include programming,
MicroStation®, GeoGraphics™, and relational databases.
Some articles describe aspects of
MicroStation software development,
and others provide code examples.

MicroStation® Visual Basic for Applications™ (MVBA)

We've written a
miscellany of VBA tips,
plus some longer articles listed here.
We also answer that common question: "Where is MicroStation VBA Help?"

MVBA is Bentley
Systems' adaptation of the Microsoft VBA toolkit. It provides a subset
of Visual Basic™ (VB) functionality and is
similar to the VBA
implementations in Microsoft Word™, Excel™ and
applications from third-parties.
A MicroStation installation includes a VBA Help file,
which provides extensive documentation and example code.

See our
books page for information about books that may be interesting to MicroStation developers.

Where MVBA differs
from other VBA implementations is its support for
MicroStation. Just as VBA for Microsoft Word provides
programming models for words and paragraphs,
MVBA provides programming models for graphic
elements, reference models, keyin commands, and
many other features unique to MicroStation.

MVBA uses VB syntax and is easy to learn: there are many books and other tutorials
available for Visual Basic beginners. The Interactive Design
Environment (IDE) is similar
to the IDE in Word and Excel, and not too dissimilar to the IDE in VB
itself.

VBA Tools

VBA Interactive Development Environment

VBA's Interactive Development Environment (IDE) provides a lot of tools to help you.
Explore the IDE. Take a VBA training class.

VBA Debugger

VBA includes debugging tools.
Function key F8 lets you step through your code and examine the state of your variables.
The
Debug
object is your friend.
Debug.Print "Trace message" gives you information that only you can see in the IDE.
See also the MicroStation
Message Center that can provide debug data to your users.

Mouse Wheel Support

One irritating failing of VBA, and Visual Basic as well, is its lack of support for a mouse wheel.
That is, you can't use the wheel on your mouse to scroll through code in the VBA IDE.
However, Microsoft has published a fix for this problem.
Visit this link to learn
how to enable mouse-wheel scrolling
in both VB and VBA.

Record a Macro

One of the simplest ways to get started with VBA is to record a macro.
Use MicroStation menu Utitilities|Project Manager to pop the VBA Project dialog.
The record macro buttons let you capture your user actions as a VBA recording.

VBA and .NET

Q How can I use VBA with .NET?

A A common question that has no simple answer.
VBA and .NET are both Microsoft technologies.
However, VBA predates .NET by several years.
Unfortunately, they don't work together.

It's possible to write functionality using .NET that you can use from VBA.
The trick is to write a DLL using your favourite .NET language,
and make that DLL COM-compatible.
Use Visual Studio .NET to
develop a COM server implemented in a DLL.
This
article
shows the tricks and pitfalls.

Visual Basic is not VBA

Microsoft provides Visual Basic for Applications to software vendors in its VBA Toolkit.
The vendor uses the VBA Toolkit to implement and customise VBA for their application.
VBA generates binary code that is tightly coupled to the host application.
The code is in a container whose nature depends on the vendor's policy.
For example, a Microsoft Excel™ VBA project is stored in an Excel workbook or add-in.
A MicroStation VBA project is stored in a .mvba file.

Visual Basic cannot read a .mvba binary file.
If you want to move VBA code to a VB project, then you should export the source code from the VBA project.
Export code from the VBA Interactive Development Environment (IDE) by
right-clicking in the Project window and choose the Export option from the pop-up menu.

Trademarks

All trademarks are
acknowledged. Trademarks may be registered in some jurisdictions.
Contact LA Solutions using this enquiry form.