Modal Form

I have a single Form (a simple one, just a message and an OK button to Unload and End) that I wish to display in Modal style.  I could not find a Property for this, so I created a Sub Main Module as the startup and put in the following: vbModal

But this does not work.  When I click outside the Form, it minimizes to Task Bar.

How do I create a single Modal Form?
Who is Participating?
clifABBConnect With a Mentor Commented:
I am unable to duplicate this problem.
What I did so was run it and click on the VB IDE which came to the front hiding the form (but it did not minimize).  Is this possibly what happened?  Try minimizing the VB IDE and see if the form is underneath.

If this is what happens, this is the way vbModal does work.  I believe what you are trying to accomplish is to keep the form on top of all other windows.  You can do this with this code:

In the declarations section of a module paste this code:
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Const HWND_TOP = 0
Public Const HWND_BOTTOM = 1
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const SWP_SHOWWINDOW = &H40

Use This code to show your form:
Call SetWindowPos(Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_SHOWWINDOW)

if it's just a messege and an ok button, why don't you call a system modal msgbox from the form, and set the form.visible to false
jalymoAuthor Commented:
clifABB --

Look's good!!  Before I give you your points, could you answer a couple more questions --  This Form will be a logon message that will be initiated by our Network logon script and seen by hundreds of machines, from some 486s to P300s.  I'm going to do a "make .exe" and have the network guy execute it from his batch script.  

Do you see any problems with this program running on different machines?  Can the .bat file run my .exe?

"Do you see any problems with this program running on different machines?"
No, as long as they are all Intel machines this should be ok.
"Can the .bat file run my .exe?"
Yes, from Win95 and up and WinNT 4.0 and up.
jalymoAuthor Commented:
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.