Tips Tagged: VBA

Save User Inputs as Default Settings

Written by Rod Wing.   Many times in a macro you want to save user input so that it is stored and then recalled as the program’s default values the next time they run your application. This can be done by writing these values to an ini file, or some other formatted ascii file, then [...]

ByRef and ByVal

Written by Rod Wing.    The ByRef and ByVal keywords are used when passing variables to subroutines and functions. Passing arguments by reference (ByRef) passes the memory location of the variable which means that any changes made to the variable during the procedure are permanent. Passing arguments by value (ByVal) only passes a copy of [...]

Putting your Macro to Sleep

Sometimes it is necessary to suspend the operation of your macro for a certain length of time. There is no native function to do this in VBA so we are left to our own devices. The Empty Loop Some of you may have tried the empty loop trick mimic a sleep function. This involves some [...]

Reading/Writing Text Files

Being able to read from and write to text files in VBA is useful for the import/export of coordinate data as well as other file and configuration parameters. Opening Files To work with a text file you will typically need to dimension three variables: A String variable for the file name     Dim txtFileName As [...]

Learning VBA

Have you purchased VBA books in the past hoping to teach yourself how to create VBA macros? While there are excellent, comprehensive, reference books available, they can be very overwhelming for non-programmers making it difficult to learn from. That’s what we’ve heard from a lot of clients. This is why EnvisionCAD developed the “MicroStation VBA [...]

Arrays

Efficient Array Looping VBA provides the LBound and UBound functions for retrieving the lower and upper bounds of an array.  When looping through an array many developers will conserve lines of code by putting the LBound and/or UBound functions in the loop test statement. This can decrease the performance of your application as these functions [...]

MicroStation Messages

MicroStation is fairly consistent in how it displays prompts and messages in the Status bar at the bottom of the window. To make your macros mimic standard MicroStation commands you should display messages in these areas as well. ShowCommand The ShowCommand method displays a string expression in the Command field of the status bar. ShowCommand [...]

MicroStation VBA Fundamentals Manual and Class

Written by Bob Mecham. MicroStation VBA Fundamental Training and Manual from EnvisionCAD EnvisionCAD is pleased to announce our newest class offering and manual “MicroStation VBA Fundamentals“.  This course is for non-programmers to learn how to create their own MicroStation VBA macros to increase productivity for repetitive tasks and add their own commands to the MicroStation [...]

Toolsettings Key-ins

The CadInputQueue.SendCommand and CadInputQueue.SendKeyin methods are easy ways for programmers to automate MicroStation tasks in their VBA macros.  One problem that users encounter is how to adjust the Tool settings for a particular command. As it turns out there is a key-in command that can help with that as well. To find the Tool settings [...]

Message Boxes

Written by Rod Wing. Message Boxes are a means to quickly display information to the user.  Message boxes can also used to get basic Yes/No or Boolean type user input. Using Message boxes to get this kind of input can eliminate the need to develop custom UserForms to gather that information. The MsgBox function returns [...]

« Older Entries
Privacy Policy