I have several variables I want to be able to set and then use throughout my project. I can think of two ways to do this, but I don't know which would be best.
First, and seems simplest, would be to just Public Shared the variables. Set them as required, call them when needed.
Second would be to create an object and assign the variables as properties to that object. It would take more programming to do this option. The beauty of this would be that I could store the values from drawing session to drawing session and would not have to ask the user for the values every time he starts my program. Can this be a custom dictionary object? Is that how you would design it?
Unless there is a way to make my Public Shared variables hold their values when the drawing is closed. Static doesn't seem to work here, but I could be missing something.
Thanks if you can help,
>> Unless there is a way to make my Public Shared variables hold their values when the drawing is closed
In my understanding the word "variable" is a name as a placeholder for storing data/value/object/adress in memory ... not in a file. That said it makes the biggest difference if you need the value to be stored with each drawing or you need it just in memory and the values can get lost e.g. when you close AutoCAD.
"Public" in a modul or "Public Shared" in a class/class-instance makes no difference, a value you store into it is global for your complete VBA-project. If you want to have a variable for each drawing you should create classes and create an instance from the class-definition for each drawing. Then you should not use the "Shared" phrase as this would not be individual by instance.
HTH, - alfred -
If your intent is to store a variable in the drawing then you best option is to use a custom dictionary to store the value locally into the drawing or store the value into the registry.
Access a broad range of knowledge to help get the most out of your products and services.