Questions similar to this appear on the MicroStation Programming Forum. These problems appeared in the VBA discussion group.

Introduction

This post answers the question: "How do I perform an arithmetic computation of the values displayed in a set of numbers?" To answer that question, we must first define what we mean by numbers. MicroStation stores geometric data in various types of element, such as line-strings and circles. MicroStation has a text element (a VBA TextElement), but it doesn't have a number element. If you see numbers in a MicroStation DGN model, they are either dimension elements, tag elements or text elements.

Other topics about Text Elements include Text Element Analysis with VBA.

If you're interested in programming Text Styles with VBA, there's a separate page.

Q How do I get the sum of a set of numeric TextElements ?

A First, you need to identify a set of text elements. The MicroStation idioms for that task are either a selection set or a fence. Once you've identified the set of interesting text, you need to run some code that analyses them.

VBA Project: AddNumbers.mvba

AddNumbers.mvba is a complete, working, VBA project. It performs the task described above. If you want to add a set of numbers stored in MicroStation text elements …

  1. Download the ZIP file that contains the VBA project
  2. Copy the VBA project to a location that MicroStation knows about. A suitable folder, for example, is
    \Workspace\Standards\vba
  3. Start MicroStation
  4. Select some numeric text, or place a fence around some text
  5. Run the VBA macro using the key-in
    vba run [AddNumbers]modMain.Main
  6. At this point the sum of the numbers is created as a text element. The text element is stuck to your cursor. Datapoint to place the text in your DGN model.

Download VBA Project

You can download the VBA AddNumbers Project as a ZIP archive. Unpack the ZIP archive and extract AddNumbers.mvba to a suitable location, such as \Workspace\Standards\vba.