Userforms @ runtime

Userforms @ runtime

Anonymous
Not applicable
444 Views
7 Replies
Message 1 of 8

Userforms @ runtime

Anonymous
Not applicable
I have a userform that i have created at runtime. I've done what i wanted to do with it. Now i can't seem to get it to unload. When my dvb is loaded there is no "Userform1" and when the code has executed i want it to remove the form called "Userform1". How can i get it to do this?
0 Likes
445 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
I don't quite get what you mean. Please rephrase. What do you mean by "When my dvb is loaded there is no "Userform1"", and what do you mean by "remove the form called "Userform1""?
0 Likes
Message 3 of 8

Anonymous
Not applicable
I meant, since my userform is created at runtime when the dvb is loaded into the drawing it doesn't exist. so at runtime the userform is created, i do my work with it, then i need to unload it. I can't get it to unload. Need some help
0 Likes
Message 4 of 8

Anonymous
Not applicable
Wow... please spend some time to put commas where they should be.....


What doesn't exists?
"I meant, since my userform is created at runtime[,] when the dvb is loaded into the drawing it doesn't exist."

or

"I meant, since my userform is created at runtime when the dvb is loaded into the drawing[,] it doesn't exist."

Choose.



Any way, it depends if your form is modal (witch is probably the case). If so. Create a button labeled Close and put this code in its click event : "Unload me" or "Me.Hide"

I think that's what you mean. If not, please specify....
0 Likes
Message 5 of 8

Anonymous
Not applicable
I don't know how else to explain it. When your in the IDE within autocad you have your categories in the project explorer. You have Autocad Objects, Forms, and Modules. When my dvb is loaded into the drawing, the "Forms" category does not exist because there is no form present. The form is created at runtime. So after the form has been created and i have done what i needed to do with it, i want the Form i've just created to be removed. Deleted from the dvb project. So when i run the program again it will generate a new form.

The problem i'm having is that i'm dynamically creating controls on a product based need. So each time the program runs it will be in the need of different controls. So i either need to remove the form every time the program runs or i need to clear the forms controls after each execution. I don't know how to do either.
0 Likes
Message 6 of 8

cgay
Enthusiast
Enthusiast
See here:

http://www.cpearson.com/excel/vbe.htm

While this info applies to VBA in Excel, it should be very similar to VBA in AutoCAD.

FYI: You cannot delete a Userform while it is in use. You'll need to ensure that it is unloaded from memory or you may crash AutoCAD.
0 Likes
Message 7 of 8

Anonymous
Not applicable
Try this:

Unload UserForm1
0 Likes
Message 8 of 8

cgay
Enthusiast
Enthusiast
He is not trying to unload the userform from memory, he is trying to delete the userform from the dvb. My take on it is he is dynamically generating code modules( in this case a userform) using VBA extensibility. While I personally wouldn't go this route do to it's complexitiy, the link I posted should give you the info on how to delete a dynamically created code module (be it a module,form, or class).

FYI: the 'Unload' procedure unloads an object from memory (i.e. the current execution context) but it still remains in the project. The only way to remove an item from any VBA project is to use the Visual Basic Application Extensibility 5.3 library. This also means that the VBA implementation must allow access to the VBE object (AutoCAD does, as well as most Microsoft VBA implementations, like office).

Good Luck,

C
0 Likes