Annoying Dialog Box Behavior, Populating with Previously Used Values

Have you ever noticed that annoying Dialog Box behavior where it (sometimes) populates with previously used values (usually when you
don't want it to), rather than the initial values you specified...I finally figured a way around it.
Since SolidWorks actually keeps macros open in the background after you run them as discussed in:
Even tho I Unload the Form at the end of each macro, I think somehow it is not getting completely unloaded. I noticed that values set in any Procedures not under a dialog box, seemed to always work. But values specified in the UserForm_Initialize event or even just the default values of the dialog box...where not being correctly initialized during subsequent runs of a macro during a SolidWorks secession. After some experimenting, and finally getting it to repeat I found that the UserForm_Initialize event procedure was not being called during the runs that were populating with the previously used values.
The solution that seems to be working so far is to add a "Unload Userform1" line right before the "Load Userform1" call. If you have multiple "Load Userform1" line calls (if for whatever reason you are opening and closing a Userform multiple times during a single processing of the macro), then you only need to add the "Unload Userform1" line before the *first* "Load Userform1" call.
Later, Ken
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
Add image file
Upload is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.