Results 1 to 2 of 2

Thread: Try Catch Finally End Try and On Error Goto

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784

    Try Catch Finally End Try and On Error Goto

    Dear The Expert,

    I am new with VB.NET (previously VB6 Developer) .. what I want to ask is simple:

    1. What 's the difference between Try .. Catch .. Finally End Try and On Error Goto ErrorHandler ...
    2. Which one better?

    I need advice

    Thanks

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    Try..Catch..Finally is used for times you know your code may cause an error, and you know what error it may be.
    VB Code:
    1. Try
    2. 'code to cause error
    3. Catch 'you can have arguments here, eg: Catch When ErrNum = 5
    4. 'code to execute if theres an error
    5. Finally
    6. 'this code is always executed once the Try or Catch code is finished
    Its generally good programming practise to stay away from using Goto statements, and I believe this to be also the case with Error handling.

    Hope this helps..

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width