Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

visual basic x out of application

Posted on 2006-06-28
5
Medium Priority
?
286 Views
Last Modified: 2013-11-25
I have an application that communicates with another machine.
I don't want people to be able to x out of the application.

I have code in the form unload that exits the sub, but the form still unloads.

How do I prevent this?
0
Comment
Question by:jackjohnson44
5 Comments
 
LVL 66

Expert Comment

by:Jim Horn
ID: 17002941
You can disable the 'X' button in the upper right by setting the form's Control Box property to False.
As far as making it invisible, I am not sure if this is possible.

>I have code in the form unload that exits the sub, but the form still unloads.
This assumes that you have an means of causing the unload event to happen, such as your own Close button.

Hope this helps.
-Jim
0
 

Author Comment

by:jackjohnson44
ID: 17003204
I tried that, and I got an error.
"Function or interface marked as restricted, ..."

Are you sure controlbox should be set to false?
There is no intellitype for true or false here.
0
 
LVL 13

Accepted Solution

by:
Mark_FreeSoftware earned 2000 total points
ID: 17003345
that cannot be set on runtime


try this code:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
   If UnloadMode = 0 Then
   'unload mode = 0 when the user presses x or presses alt+f4
      Cancel = 1
   End If
End Sub


0
 
LVL 20

Expert Comment

by:hes
ID: 17003686
If you want to disable the x button at runtime see here:

http://www.freevbcode.com/ShowCode.Asp?ID=2448
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17015696
Disabling the control box will prevent minimize or maximize from being shown but it is easy to exit the application.

Adding the cancel=1 will prevent the program from closing unless terminate process is used.

Are you also trying to prevent ALT + F4?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question