Solved

visual basic x out of application

Posted on 2006-06-28
5
284 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month6 days, 7 hours left to enroll

634 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