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

modeless dynamics userform

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
1314 Views, 7 Replies

modeless dynamics userform

Hi,

I'm writing a Vba module , who dynamicly create a userform with some
objetcs.

If the userform is modal , the module work fine , but , if the userform is
modeless ,
the userform appair and immediatly disappear without any error message.

after testing , I see than the problem occurs then I'm adding source code to
the
CodeModule object of the userform (for the included objects).

Apparently , then adding objects , the VBE reinitialize some vars or objects
..

Can everyone give me an explanation and/or a work-around ?

joined is a sample of the problem.

Regards

Luc
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

I think what is happening is this:

1) with a Modal Form, control passes to the form and is not returned until the form is hidden -- the form act much like a Sub or Function call.

2) with Modeless, the form is shown, but execution continues in the calling routing. When the End Sub is reached, the form variable goes out of scope and is terminated -- this causes the form to be unloaded.

I do not do much with VBA (using VB instead). In VB, your basic technique (using a Public variable) would work -- I use it all the time. VBA apparently works differently.

One possibility would be to use the QueryClose event in the form and cancel the close if it did not originate from the User clicking the Form Close RedX. I am not sure how to add this event to the form the way to are handling the form.

Hope this helps.

Victor
Message 3 of 8
fxcastil
in reply to: Anonymous

cesi

I have also noticed the same problem before, try enclosed sample as is, then change the command

Userform1.Show ' change to line below and try
Userform1.Show vbModeless

Fred Castillo
Message 4 of 8
fxcastil
in reply to: Anonymous

cesi

I have also noticed the same problem before, try enclosed sample as is, then change the command

Userform1.Show ' change to line below and try
Userform1.Show vbModeless

Fred Castillo
Message 5 of 8
Anonymous
in reply to: Anonymous

thanks for you help, but

1) pvictor : the problem occur only if we add lines of code directly in the
code module ,
if you suppress this part of code , the dvb work good but incompletly
adding a query_close section don't solve the problem (no action then the
window close)

2) fxcastil :this don't work , the show command in the creation sub don't
display the windows ,
and we need this

idea : adding code lines in the codemodule object generate a project
reinitialization (like when you create
a new sub section when a project is loaded and working) , this explain the
visuals effects.


Luc
Message 6 of 8
Anonymous
in reply to: Anonymous

Hi,

Would you help me on this please. I am getting the same error, however it functions as expected. I understand that by default it shows the form.

My Code below; i am initializing my form when it is loaded with some values. Let me know how to avoid this error. This is for Inventor

 

Public Sub UserForm_initialize()

ComboBox1.AddItem ("A0")
ComboBox1.AddItem ("A1")

UserForm1.Show Modeless

End Sub

 

 

 

Thanx in Advance

Message 7 of 8
Anonymous
in reply to: Anonymous

OK. I found out that in my User Form i need to change the Show modal option to False 🙂

THanx anyways 🙂

 

Message 8 of 8
Anonymous
in reply to: Anonymous

OK. I found out that in my User Form i need to change the Show modal option to False 

Thanks anyways 🙂

 

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report