473,473 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

end without form unload

Have had a complete brain-fart and cannot think of how to stop code
execution without unloading the form in vb.net. In other words, if my
code catches an error, I want it to tell the user and stop execution
so the user can fix the error and restart the code without unloading
the app.

Shawn
Nov 18 '08 #1
7 2508
A bit unclear. You can't both "stop code execution" and do that "without
unloading the application".

Or do you mean that your application code should just go out of its usual
flow (using try/catch ? by handling unhandled exceptions ?) before resuming
its usual flow...

If you want to restart I believe there is also a Application.restart method
that relaunch the application in a clean state.

As a side note be wise with that as trying to keep running whatever is the
error you get is IMO not necessarily always a good idea (it can make things
worse).

--
Patrice
"Shawn" <sa***********@gmail.coma écrit dans le message de groupe de
discussion :
1f**********************************...oglegroups.com...
Have had a complete brain-fart and cannot think of how to stop code
execution without unloading the form in vb.net. In other words, if my
code catches an error, I want it to tell the user and stop execution
so the user can fix the error and restart the code without unloading
the app.

Shawn

Nov 18 '08 #2
I have a form with a ton of fields to fill by the user. The entries
must fit certain criteria and that is checked during runtime. If an
entry fails a criteria the code should end and tell the user why it
stopped. However. I do not want the form to unload. If you make a
mistake typing in Word, Word does not close, it shows you the spelling
error.

Shawn
Nov 18 '08 #3
Sorry, your description make me thought you wanted to handle critical
errors.

Just use MessageBox.Show
(http://msdn.microsoft.com/en-us/libr...ebox.show.aspx)
to show a message to the user or you could use the ErrorProvider object to
display an error icon next to all erroneous fields
(http://msdn.microsoft.com/en-us/libr...provider.aspx).

--
Patrice

"Shawn" <sa***********@gmail.coma écrit dans le message de groupe de
discussion :
8e**********************************...oglegroups.com...
I have a form with a ton of fields to fill by the user. The entries
must fit certain criteria and that is checked during runtime. If an
entry fails a criteria the code should end and tell the user why it
stopped. However. I do not want the form to unload. If you make a
mistake typing in Word, Word does not close, it shows you the spelling
error.

Shawn

Nov 18 '08 #4

"Shawn" <sa***********@gmail.comwrote in message
news:8e**********************************@v39g2000 pro.googlegroups.com...
>I have a form with a ton of fields to fill by the user. The entries
must fit certain criteria and that is checked during runtime. If an
entry fails a criteria the code should end and tell the user why it
stopped. However. I do not want the form to unload. If you make a
mistake typing in Word, Word does not close, it shows you the spelling
error.

Shawn
What you want to research is Validate. Ensure that the CausesValidation
property is set to True for all fields where you want to validate. Then
handle the Validating event for the control on the form. This will fire
when you attempt to move focus to another field.

Depending on your logic you can also use the ErrorProvider for display
purposes.

LS

Nov 18 '08 #5
On Nov 18, 8:37*pm, Shawn <saquisenbe...@gmail.comwrote:
I have a form with a ton of fields to fill by the user. *The entries
must fit certain criteria and that is checked during runtime. *If an
entry fails a criteria the code should end and tell the user why it
stopped. *However. I do not want the form to unload. *If you make a
mistake typing in Word, Word does not close, it shows you the spelling
error.

Shawn
As far as i understood, you want your users to be prevented from
closing their form with notifying the close reason, if so, you can use
FormClosing event handler to notify close reason with keeping form
alive when a problem occurs in your form.

In FormClosing event handler, use "e.CloseReason" enum to notify
reason, and e.Cancel = True to keep form alive.

However, based on your wish, you can also use a Try-Catch and put a
notification method in Catch like a MsgBox then your users will have
another chance to re-fill the required fields on your form.

Not sure, but i hope that gives you an idea about the pattern,

Hope this helps,

Onur Güzel
Nov 18 '08 #6
On Tue, 18 Nov 2008 10:37:15 -0800 (PST), Shawn
<sa***********@gmail.comwrote:
>I have a form with a ton of fields to fill by the user. The entries
must fit certain criteria and that is checked during runtime. If an
entry fails a criteria the code should end and tell the user why it
stopped. However. I do not want the form to unload. If you make a
mistake typing in Word, Word does not close, it shows you the spelling
error.

Shawn
Where is this checking performed? If your code doesn't call the
form's Close method, the form won't close.
Nov 18 '08 #7
Shawn wrote:
I have a form with a ton of fields to fill by the user. The entries
must fit certain criteria and that is checked during runtime. If an
entry fails a criteria the code should end and tell the user why it
stopped.
All perfectly reasonable and there are /many/ ways to accomplish it,
practically /none/ of which involve closing the Form.
However I do not want the form to unload.
It won't; unless you tell it to.

Or ...

.... if you allow an Unhanded Exception to propagate out of your code,
causing the entire application to crash and burn.

Don't let that happen.
Anywhere the user can initiate an action (loading the form, clicking a
button, etc., etc.), you should have at least one Exception handler
(Catch block) so that there are [hopefully] /no/ unhandled Exceptions.
That way, you can deal with (i.e. handle) anything that goes wrong
unless, of course, it goes /so/ far wrong that there's probably nothing
you can do about it anyway, like an Out of Memory error.
If you make a mistake typing in Word, Word does not close,
it shows you the spelling error.
Now, now. Don't go giving Our Friends in Redmond ideas ...
They forced us to adopt "The Ribbon". Why shouldn't they insist that we
never make a single spelling miztake? ;-)

HTH,
Phill W.
Nov 19 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Matthew Wells | last post by:
I am trying to load a form (load Me) without the form becoming visible. If I try me.hide or me.visible = false, they load the form and the form blinks before becoming invisible. Is there a way to...
10
by: peter hansen | last post by:
I tried a couple of weeks ago but I'll try again :D I old VB6-days it was possible to unload a form bu using the Unload(Form) command. I have tried the Close-function but it'll unload the entire...
15
by: carr4895 | last post by:
Hello. I was wondering if someone could help me too with a login form. Upon startup, I have to display a password screen and it should accept a user name and password. User name can be anything...
5
by: AP | last post by:
IS there a way to run a procedure if the users close access directly rather than closing a menu screen that I have built? There is an event that works on close for this form, but it doesnt seem to...
3
by: lesperancer | last post by:
I've got application A, with a hidden form, whose unload event is cancelled unless you use an 'exit' button (so I can do special processing) this works fine when using just application A and it...
1
devonknows
by: devonknows | last post by:
Ok, i posted about forcing a form to unload, now since ive implemented that, when check1.value = true, when you close the form, it doesnt unload, when check1.value = false, it unloads perfectly and...
13
by: PW | last post by:
Hi, This is bizarre. I've check and rechecked the spelling, cut and paste the name of the form (when trying to rename the form) and the control yet I still get a parameter prompt when the form...
6
by: Ronald S. Cook | last post by:
We have a Windows app that has one main form (a shell, sort of). We then load user controls into a panel on the form depending on what the user has selected. Our current code to unload the...
6
vdraceil
by: vdraceil | last post by:
I use vb6.i have a small problem guys..my form is not unloading. I want my application to end only if the user presses shift+F10.so i run a timer with interval=1 which checks the keyboard state of...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.