Software\Version:
Visual Basic 2010 Forms and Applications
Issue:
Application shows unhandled exception error message
Question:
How do you disable, or auto-click continue on all "Unhandled Exception" error messages?
Thanks for helping.![]()
Software\Version:
Visual Basic 2010 Forms and Applications
Issue:
Application shows unhandled exception error message
Question:
How do you disable, or auto-click continue on all "Unhandled Exception" error messages?
Thanks for helping.![]()
If you know where the exception is occurring, I think you can put "On Error Resume Next" on the line above, and it will contimue to the next line. Not sure why you would want to ignore exceptions though!
First off you should never use On Resume Next, as it is bad to ignore errors. Instead use assertion i.e.
This is not good if the file does not exist.
Best to check if the file exists first, this is assertion.Code:IO.File.Delete("Somefile.txt")
For unexpected exceptions you can override the default unhandled exception handler, see attached VS2010 project, compile, run outside of the IDE then inside the IDE. Next look at the error log file created in the app executable folder.Code:Dim fileName As String = "Somefile.txt" . . . If IO.File.Exists(fileName) Then IO.File.Delete(fileName) End If
Bottom line is write tight code, test well and when there is an unexpected error write assertion to trap for this and as a last resort use Try/Catch and never leave the Catch section empty.
Thanks.
On Resume Goto Next worked... lol
Errors are created by user input, hard to explain but the error is unavoidable,
and a msg box for it could go bad/several, + handling it may create negative effects/wait/lag
the error has an ending statement ending on error goto next for all, so no loops.
Last edited by VBbbq; Jun 20th, 2012 at 08:52 PM.
2007-2013
Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs
MSDN "How Do I?" Videos: VB | C#
VBForums Database Development FAQ
My CodeBank Submissions: VB (*NEW* Match Two Game, *NEW* More Random Random Numbers) | C# (*NEW* Match Two Game, *NEW* More Random Random Numbers)
My Blog: Using Parameters in ADO.NET | Keyboard Events | Assemblies & Namespaces
example code with issue:
If inputidval.Text <> "" And inputid.Checked Then
On Error Resume Next
WebBrowser1.Document.GetElementById(inputidval.Text).SetAttribute("Value", inputidnew.Text)
End If
End Sub
when the user puts in a name thats not valid, it would return errors
if the name they put in wasnt available in webbrowser1.document
not sure how to resolve it other than the on error resume next thing, it
worked, is there a better solution?
im not sure how to write the io.file.exists statement for
WebBrowser1.Document.GetElementById(inputidval.Text).SetAttribute("Value", inputidnew.Text)
sounds hard.. :/
heres a working snippet / example app code
Dim CodeElements As HtmlElementCollection = WebBrowser1.Document.All
For Each codeElement As HtmlElement In CodeElements
Dim code2Element As String = codeElement.GetAttribute("src").ToString
If code2Element <> "" And codeid.Checked Then
txtID.Text += "HTML SOURCE: "
txtID.Text += code2Element
txtID.Text += vbCrLf
numElement += 1
txtElements.Text = numElement
End If
if it helps / request for code
thanks for responding.
Last edited by VBbbq; Jun 20th, 2012 at 11:50 PM.
Presumably you get a NullReferenceException on this line:when the first TextBox contains an ID that doesn't exist. The solution is simple and you have already been provided with it. Simply assign the result of GetElementById to a variable and then test whether that variable is Nothing. If it is then the ID doesn't exist so you don't call SettAttribute. If it's not then you call SetAttribute on the variable. ALWAYS look before you leap, i.e. test the data before you use it and only use it if it's valid. There are very few scenarios where you can't do so.Code:WebBrowser1.Document.GetElementById(inputidval.Text).SetAttribute("Value", inputidnew.Text)
2007-2013
Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs
MSDN "How Do I?" Videos: VB | C#
VBForums Database Development FAQ
My CodeBank Submissions: VB (*NEW* Match Two Game, *NEW* More Random Random Numbers) | C# (*NEW* Match Two Game, *NEW* More Random Random Numbers)
My Blog: Using Parameters in ADO.NET | Keyboard Events | Assemblies & Namespaces
Thanks again, I appreciate the help. Everything resolved!
woot
/topic finished![]()
Last edited by VBbbq; Jun 22nd, 2012 at 03:41 PM.