Error Codes In Vb.net
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. .NET Development Articles and Overviews Upgrading to Microsoft .NET Upgrading to Microsoft .NET Error Handling in Visual Basic .NET Error Handling in Visual Basic .NET Error Handling in Visual Basic .NET ADO.NET for the ADO Programmer Building an N-Tier Application in .NET Calling a .NET Component from a COM Component Calling COM Components from .NET Clients Common .NET Libraries for Developers Comparing System.Xml in Visual Studio .NET to Microsoft.XMLDOM in Visual Studio 6.0 Converting ASP to ASP.NET Creating Classes in Visual Basic .NET Creating Components in .NET Creating a Windows Form User Control Data Binding with Windows Forms and ADO.NET Designing a .NET Application Designing for Web or Desktop? Determining When to Use Windows Installer Versus XCOPY Differences Between Visual Basic 6.0 and .NET Controls Distributed Transactions in Visual Basic .NET Error Handling in Visual Basic .NET Getting Started with Windows Forms Inheritance and Interfaces Inheritance from a Base Class in Microsoft .NET Interacting with Message Queues Introduction to ASP.NET and Web Forms Introduction to Visual Studio .NET Managing Versions of an Application Migrating from the SOAP Toolkit to Web Services Overloading Methods in Visual Basic .NET Performing Drag-and-Drop Operations Raising Events and Responding to Events Replacing API Calls with .NET Framework Classes Structuring a .NET Application For Easy Deployment Understanding and Using Assemblies and Namespaces in .NET Using ActiveX Controls with Windows Forms in Visual Studio .NET Using ADO.NET Using COM+ Services in .NET Using Web Services Instead of DCOM Variable and Method Scope in Microsoft .NET Working with MDI Applications and Creating Menus T
.NET Framework > Visual Basic Question 0 Sign in to vote Hello everyone.... This is Abhijit Annaldas, I am a VB.NET developer. I want a compiled list of all error codes and messages in vb.net. I want to display a user friendly message instead of the following method... --------------------------------------------------------------------------- Try .......... Catch ex as Exception MsgBox(ex.message.tostring()) End Try --------------------------------------------------------------------------- If i get this i would do it as... For Eg: In case of duplication of a primary key field value in the Database. --------------------------------------------------------------------------- Try https://msdn.microsoft.com/en-us/library/ms973849.aspx .......... Catch ex as Exception If errcode=
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads http://stackoverflow.com/questions/5094187/err-number-vs-try-catch-in-vb-net with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Err.Number vs try-catch in VB.net up vote 4 down vote favorite I have inherited an old VB.net-project. The code mostly uses try-catch for error-handling. However in some places I have found If Err.Number <> 0 Then. If an error error codes occurs, what decides if an Exception should be thrown, or just setting Err? I don't want to handle error both ways... vb.net exception-handling try-catch share|improve this question edited Feb 23 '11 at 17:09 Fredrik Mörk 109k15206284 asked Feb 23 '11 at 17:03 leiflundgren 1,30522147 2 The infamous On Error Resume Next. –Hans Passant Feb 23 '11 at 17:16 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote accepted The Err object is use with the old-style On error codes in Error error handling construct, that is a remainder from classic VB. Try-Catch is the more current .NET style of error handling. You can learn more about this, and the difference in Error Handling in Visual Basic.NET. share|improve this answer edited Feb 23 '11 at 17:13 answered Feb 23 '11 at 17:05 Fredrik Mörk 109k15206284 How do I decide which error handling is active? Just On Error Goto 0 should set old-style, I think. –leiflundgren Feb 23 '11 at 17:05 @leiflundgren: whatever construct is closest to the code you are looking at will be the active one. You can mix both styles, but not within a method. So you can have one method setting up error handling with an On Error statement, and then call another method that uses Try-Catch. –Fredrik Mörk Feb 23 '11 at 17:07 @fredrik-mork: Ah So if I write On Error Goto 0 (or similar) in a method, I use that stile. Otherwise it's try-catch? –leiflundgren Feb 23 '11 at 17:09 @leiflundgren: yes, almost correct. In order to use Try-Catch you will of course need to include such statements in your code. If you have neither On Error nor Try-Catch, any exceptions will be unhandled and crash your app instead. –Fredrik Mörk Feb 23 '11 at 17:11 @fredrik-mork: Ah. The fault was assuming existing code was correct. ;) Added try-catch as I am used to now. Thanks! –leiflundgren Feb 23 '11 at 1