473,805 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Try Catch Error Handling

=============== =============== =============== =============== =====
How do I use Try Catch error handling when a timer is involved?

If I preform the preciduer below and I get an error I revive
50,000,000,000, 000,000, messageboxes..
example 1;
Private Sub Button4_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button4.Click
Try
If Label13.Text = ("some text") = False Then
Button3.BackCol or = System.Drawing. Color.FromArgb( CType(224,
Byte), CType(224, Byte), CType(224, Byte))
Button3.Text = ("some more text")
Timer5.Enabled = True '<<<<<<<<<<<< say this timer is error
free!
Timer6.Enabled = True '<<<<<<<<<<<< say this timer ha an error
and it kicks an exception error!
End If
Panel1.Visible = False
Catch ex As Exception
Dim proc As System.Diagnost ics.Process
Dim pList() As Process
pList = Process.GetProc essesByName("so me app")
For Each proc In pList
Dim resp As MsgBoxResult
resp = MsgBox("Error 0020 some error, Do you wish to Exit "
& proc.ProcessNam e & "?", _
MsgBoxStyle.Yes No, "app error")
If resp = MsgBoxResult.Ye s Then
proc.Kill()
If resp = MsgBoxResult.No Then
Application.DoE vents()
End If
End If
Next
Exit Try
Finally
End Try
End Sub

If an exception error happens with the above code I get
50,0000,0000000 000000,00000,00 0,0,0,00,,0,0,0 ,0,0,0,0,+1 messageboxes!
This next example works fine but it seames to me that it's overkill to have
too write my code twice, is ther another way to acoumplish the samething if
someone clickes NO???
Example 2;
Private Sub Button4_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button4.Click
Try
If Label13.Text = ("some text") = False Then
Button3.BackCol or = System.Drawing. Color.FromArgb( CType(224,
Byte), CType(224, Byte), CType(224, Byte))
Button3.Text = ("some more text")
Timer5.Enabled = True '<<<<<<<<<<<< say this timer is error
free!
Timer6.Enabled = True '<<<<<<<<<<<< say this timer ha an error
and it kicks an exception error!
End If
Panel1.Visible = False
Catch ex As Exception
Timer5.Enabled = False
Timer6.Enabled = False
Dim proc As System.Diagnost ics.Process
Dim pList() As Process
pList = Process.GetProc essesByName("so me app")
For Each proc In pList
Dim resp As MsgBoxResult
resp = MsgBox("Error 0020 some error, Do you wish to Exit "
& proc.ProcessNam e & "?", _
MsgBoxStyle.Yes No, "app error")
If resp = MsgBoxResult.Ye s Then
proc.Kill()
If resp = MsgBoxResult.No Then
Application.DoE vents()
If Label13.Text = ("some text") = False Then
Button3.BackCol or = System.Drawing. Color.FromArgb( CType(224,
Byte), CType(224, Byte), CType(224, Byte))
Button3.Text = ("some more text")
Timer5.Enabled = True '<<<<<<<<<<<< say this timer is error
free!
Timer6.Enabled = True '<<<<<<<<<<<< say this timer ha an error
and it kicks an exception error!
End If
Panel1.Visible = False
End If
End If
Next
Exit Try
Finally
End Try
End Sub
=============== =============== =============== =============== =============== =
=

Nov 20 '05 #1
8 1699
"CarpetMnuncher !" <Ba*@mail.com > schrieb
Timer6.Enabled = True '<<<<<<<<<<<< say this timer ha an
error
and it kicks an exception error!

Where does the exception occur? In the event handler of the Timer? Is it a
System.Windows. Forms.Timer or a System.Timers.T imer?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
Cor
Hi CarpetMnucher,

If I look at your code I get the idea that you don't use use the try, catch
end try to prevent unpredictable errors. But to catch program errors.

I cannot see how a timer process can make an error in an other way that that
there is an error in the code (or the computer is damaged and than will the
try and error block also not work).

Just a thought

Cor

Nov 20 '05 #3
Hello,
Here are your reply's

ARMIN
#1,,,,Where does the exception occur? In the event handler of the Timer? Is
it a
System.Windows. Forms.Timer or a System.Timers.T imer?
Answer = If an error occurs in the event handler of the timer.
My application uses both System.Windows. Forms.Timer-s, and
System.Timers.T imer-s.

COR
#2,,,,I cannot see how a timer process can make an error in an other way
that that
there is an error in the code (or the computer is damaged and than will the
try and error block also not work).
Answer= I agree, I think I'm attempting to how would you say "over-code my
code" here.

Form ME,
Now I'm Pissed I used try catch wrong = that sucks, I did the same thing to
about 40,000 thousand pulse events which = about 200,0000 hundred thousand
lines of code which = 381 windows forms, not incliding all the modules and
ouher stuff, I think I will grab a new pack of smokes and make a hole pot
of coffee for this task looks like another sleepless night for me man = Ha,
ha, ha, cry.

"Armin Zingler" <az*******@free net.de> wrote in message
news:OK******** ******@TK2MSFTN GP10.phx.gbl...
"CarpetMnuncher !" <Ba*@mail.com > schrieb
Timer6.Enabled = True '<<<<<<<<<<<< say this timer ha an
error
and it kicks an exception error!

Where does the exception occur? In the event handler of the Timer? Is it a
System.Windows. Forms.Timer or a System.Timers.T imer?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
"CarpetMnuncher !" <Ba*@mail.com > schrieb
Hello,
Here are your reply's

ARMIN
#1,,,,Where does the exception occur? In the event handler of the
Timer? Is it a
System.Windows. Forms.Timer or a System.Timers.T imer?
Answer = If an error occurs in the event handler of the timer.
Then you must put Try-Catch in the event handler.
My application uses both System.Windows. Forms.Timer-s, and
System.Timers.T imer-s.
And those mentioned (timer5, timer6) are?

Form ME,
Now I'm Pissed I used try catch wrong = that sucks, I did the same
thing to about 40,000 thousand pulse events which = about 200,0000
hundred thousand lines of code which = 381 windows forms, not
incliding all the modules and ouher stuff, I think I will grab a new
pack of smokes and make a hole pot of coffee for this task looks like
another sleepless night for me man = Ha, ha, ha, cry.


Do you see strange colors? ;-)) I understand you very well (or good?)....
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
I figured it out, I staled up all night "cut & Paste"-ing!
A pot of coffee, 1 pack of smokes, and a trip to the 24 hr store for a new
set of wireless mouse batteries, later I got it done and it works great.
Now I do see colors red, blue, and green dots, < I guess thats whay thay
call it .NET :))

I jest wanted to say thanks for your help !
_______________ _______________ ______
"Armin Zingler" <az*******@free net.de> wrote in message
news:eQ******** ******@TK2MSFTN GP10.phx.gbl...
"CarpetMnuncher !" <Ba*@mail.com > schrieb
Hello,
Here are your reply's

ARMIN
#1,,,,Where does the exception occur? In the event handler of the
Timer? Is it a
System.Windows. Forms.Timer or a System.Timers.T imer?
Answer = If an error occurs in the event handler of the timer.


Then you must put Try-Catch in the event handler.
My application uses both System.Windows. Forms.Timer-s, and
System.Timers.T imer-s.


And those mentioned (timer5, timer6) are?

Form ME,
Now I'm Pissed I used try catch wrong = that sucks, I did the same
thing to about 40,000 thousand pulse events which = about 200,0000
hundred thousand lines of code which = 381 windows forms, not
incliding all the modules and ouher stuff, I think I will grab a new
pack of smokes and make a hole pot of coffee for this task looks like
another sleepless night for me man = Ha, ha, ha, cry.


Do you see strange colors? ;-)) I understand you very well (or good?)....
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #6
"CarpetMnuncher !" <Ba*@mail.com > schrieb
I figured it out, I staled up all night "cut & Paste"-ing!
A pot of coffee, 1 pack of smokes, and a trip to the 24 hr store for
a new set of wireless mouse batteries, later I got it done and it
works great. Now I do see colors red, blue, and green dots, < I guess
thats whay thay call it .NET :))
:-)))))
I jest wanted to say thanks for your help !


Problem solved? Glad to hear.. um.. read.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #7
Cor
Hi "CarpetMnuncher !"

I jest wanted to say thanks for your help !
_______________ _______________ ______

:-((

Only Armin?

Cor
Nov 20 '05 #8
And this is why I love software development.

=)

"Armin Zingler" <az*******@free net.de> wrote in message
news:Oo******** ******@TK2MSFTN GP09.phx.gbl...
"CarpetMnuncher !" <Ba*@mail.com > schrieb
I figured it out, I staled up all night "cut & Paste"-ing!
A pot of coffee, 1 pack of smokes, and a trip to the 24 hr store for
a new set of wireless mouse batteries, later I got it done and it
works great. Now I do see colors red, blue, and green dots, < I guess
thats whay thay call it .NET :))


:-)))))
I jest wanted to say thanks for your help !


Problem solved? Glad to hear.. um.. read.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #9

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

Similar topics

4
4352
by: Evgeny Gopengauz | last post by:
Is there something like exception handling in T-SQL? For example, how to catch an error of convertion at this sample: CREATE PROCEDURE SP @param VARCHAR(50) AS BEGIN DELCARE @var INT -- try { SET @var = CONVERT( int, @param)
7
6010
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
7
1801
by: Dan Bass | last post by:
In a somewhat complex application, I've developed plug-in architecture and am having a problem as to when to catch general exceptions for logging purposes. In each plug-in class library, for example, I'm assuming it's throw on errors, and that the core then catches them. I've got proxy classes handling some fiddly details of the plug-ins. Should I allow the exception to bubble to the top most point it can in a call stack, then catch...
37
2965
by: clintonG | last post by:
Has somebody written any guidelines regarding how to determine when try-catch blocks should be used and where their use would or could be considered superfluous? <%= Clinton Gallagher METROmilwaukee (sm) "A Regional Information Service" NET csgallagher AT metromilwaukee.com URL http://metromilwaukee.com/ URL http://clintongallagher.metromilwaukee.com/
23
3084
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally block. But, I prefer to dim them "on the fly" only if needed (save as much resources as possible). A little further... I may wish to create a sqlcommand and datareader object ONLY if certain conditions are met. But, if I want to clean these up in the...
9
3376
by: Michael MacDonald | last post by:
Does someone have a good site I can visit or explain the use of Try" and Catch foe exception/error handling. What is the logic behind this command and maybe an example would be great!!!! Mike_Mac *** Sent via Devdex http://www.devdex.com *** Don't just participate in USENET...get rewarded for it!
4
1853
by: DavideR | last post by:
I have converted a large vb6 program with an add-in that for every routine gimme the error handling: the add-in adds one line on the head of the routine "if myerrhandle then ON ERROR GOTO HERRHANDLER" and the herrhandler label at the botton where i write in a logfile the name of the routine, the errors and other information Well setting myerrhandle to true seems that the error handling keeps on working in ..net is it right? what's the...
32
6132
by: cj | last post by:
Another wish of mine. I wish there was a way in the Try Catch structure to say if there wasn't an error to do something. Like an else statement. Try Catch Else Finally. Also because I understand Finally runs whether an error was caught or not, I haven't found a use for finally yet.
23
2334
by: pigeonrandle | last post by:
Hi, Does this bit of code represent complete overkill?! try { //create a treenode TreeNode tn = new TreeNode(); //add it to a treeview tv.Nodes.Add(tn);
0
9716
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10359
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10364
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7645
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5541
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3843
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.