VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to exit routine thru a button or the "X" on the title bar

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
271 Views, 0 Replies

How to exit routine thru a button or the "X" on the title bar

Hello,

 

I have a user form and one of the buttons closes that form and exits the macro. The same is achieved by pressing the "X" button on the title bar. Until recently I used "End" function to exit the macro. I did not care about the unsightly messages on the command prompt. My problem with this approach is that when I call the macro again, the form is populated with the default values of its controls. I would like to keep the last selections which user made in the form so that next the form is show they are active. I came with the decision to use a Boolean variable which is set to true every time the user hits my closing button and also intercept the QuiryClose event and do the same when the user hits "X" button. Right after I call the show method of the form I check the Boolean variable and if its set to true I exit the routine. I set the variable to false in the activate event of the form. What annoys me is when I call the form in function/sub, called in a fun/sub, called in a func/sub. Then I need to check for this variable every time I exit func/sub in which I call my form or another func/sub calls my form. In this case three times. I am sure there is better way to achieve that.

 

Any suggestions or ideas will be greatly appreciated. Thank you.

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost