a more complicated Inputbox

In a part of my program, Form1 will call another Form namely PopForm which has some field for user to fill in. The user then click the submit button in PopForm and the program of Form1 will continue to run.

How to do that?

Just similar to Inputbox, but the different is that the popup thing is not just a line but with something complicated

PS: I use the following code in Form1:



Who is Participating?
bingieConnect With a Mentor Commented:
Load and show your popup form with

Load PopForm
PopForm.Show vbModal

When you are finished with PopForm use

Unload PopForm
Set PopForm = Nothing
leekfAuthor Commented:
could you tell me what is vbModal?
Using vbModal will force the using to enter the data in your PopForm first, i.e. it's the only form that can be accessed. They will have to close this form to go back to the main form.
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

leekfAuthor Commented:

i think this is the key

btw, why you said "When you are finished with PopForm use Unload PopForm Set PopForm = Nothing"

could you tell why i have to do that?

Also, why Load PopForm is needed?

Could PopForm.Show vbModal alone work?

Thank you so much!

Yes. But...

You will first to Load the form, if it is not already loaded, then you need to show it modally. When you are finished with it, you need to unload it, as you do with your main form, and set it to nothing. This will clear and free up memory.

Its a basic rule of thumb when unloading objects - cleans everything up.

btw - lots of info here for 25 points :-)
>> Could PopForm.Show vbModal alone work?

From MSDN on the Show method:


If the specified form isn't loaded when the Show method is invoked, Visual Basic automatically loads it.

When Show displays a modeless form, subsequent code is executed as it's encountered. When Show displays a modal form, no subsequent code is executed until the form is hidden or unloaded.

When Show displays a modal form, no input (keyboard or mouse click) can occur except to objects on the modal form. The program must hide or unload a modal form (usually in response to some user action) before input to another form can occur. An MDIForm can't be modal.

Although other forms in your application are disabled when a modal form is displayed, other applications aren't.

The startup form of an application is automatically shown after its Load event is invoked.

Here is an example of how the ownerform argument is used with the Show method:

Private Sub cmdShowResults_Click()
   ' Show a modal form named frmResults.
   frmResults.Show vbModal, Me
End Sub


So basically... yes.


leekfAuthor Commented:
> btw - lots of info here for 25 points :-)

sorry for that, i will increase a little bit.. not much point left though...

Thank you
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.