Tip 2262: Pass Strings between VBA and Visual LISP Using a Dictionary When VBA first appeared on the scene, I thought it would be great if we could use VBA's superior user interface capabilities in dialog boxes along with the more AutoCAD-intimate Visual LISP. Like other users, I quickly discovered that there was a communications gap between the two. This tip represents one way to bridge the communications gap between the two environments: using a dictionary with an Xrecord. Xrecords are nongraphic objects in a drawing that can contain data arranged in group codes. Unlike extended data in which all the group codes are in the thousands, the Xrecord group codes are just like normal entities. It's a convenient place to save and pass data between modules such as strings, numbers, points, and entity links. The function example in this tip works with just a single string, but you could expand it to meet your own needs. A dictionary named LISP_VBA (source file LISPVBA.LSP) is created and used by both Visual LISP and VBA to share data in a single Xrecord containing a string data element. To make it easier in Visual LISP, the functions (LISP->VBA) and (VBA->LISP) are provided. (LISP->VBA) has one parameter, which is a string. (VBA->LISP) has no parameters, but it returns a string. An example module (BAS file) for VBA can catch and receive data provided as part of the next tip, Use VBA for Input from Visual LISP. |