Error Handling
-
I want to prevet users from errors Should I use "On Error goto" statement or "Try catch end try" block. Although i dont want my program to rum slower due to error handling. Do you know which method is faster? Thanks in advance
Use Try/Catch dpagka wrote: Do you know which method is faster? The more important thing is that you use it correctly. It won't matter how fast one is over the other if it takes you a week to fix a bug because On Error Goto is so contrived and you introduce 2 new bugs at the same time.
My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
I want to prevet users from errors Should I use "On Error goto" statement or "Try catch end try" block. Although i dont want my program to rum slower due to error handling. Do you know which method is faster? Thanks in advance
Try/Catch blocks are very much the better way to go. Error handling doesn't add a huge overhead to your code, so I don't know why that's a concern... If your code errors out, Error Handling definately wins the speed competition, because if you don't the error, your code comes to a screeching halt. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
Try/Catch blocks are very much the better way to go. Error handling doesn't add a huge overhead to your code, so I don't know why that's a concern... If your code errors out, Error Handling definately wins the speed competition, because if you don't the error, your code comes to a screeching halt. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
sure, but you cannot apply any
Resume
... (even if - i aggree -goto
s are quite bad to use...
TOXCCT >>> GEII power
[toxcct][VisualCalc]:confused::confused::confused::confused: If your code is written correctly, why on earth would you need to? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
:confused::confused::confused::confused: If your code is written correctly, why on earth would you need to? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
while programming in console mode, this becomes very useful when getting a bad user input and want to get it again until the user type its value correctly... this can't be done with exceptions (
try
andcatch
blocks) except if you use explicitgoto
s, that behavies the same...
TOXCCT >>> GEII power
[toxcct][VisualCalc] -
while programming in console mode, this becomes very useful when getting a bad user input and want to get it again until the user type its value correctly... this can't be done with exceptions (
try
andcatch
blocks) except if you use explicitgoto
s, that behavies the same...
TOXCCT >>> GEII power
[toxcct][VisualCalc]Wanna bet?! Just a little something off the top of my head...
Dim validInput As Boolean = False
Dim choice As Integer
Do
Try
choice = Console.ReadLine()
...Whatever else you need...
If choice is valid Then
validInput = True
End If
Catch ex As Exception
...Whatever you want here...
End Try
Loop While Not validInputRageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome