+ Reply to Thread
Results 1 to 2 of 2

Thread: how to handle errors

  1. #1
    neginf is offline VB.NET Forum Newbie neginf is on a distinguished programming path ahead
    .NET Framework
    .NET 3.5
    Join Date
    Mar 2010
    Age
    51
    Posts
    1
    Reputation
    0

    Default how to handle errors

    I am making a vb.net program that calls several other subprograms. None of them effect the other.
    If there is an error in 1 of them, how do you record the error but continue on to the next subprogram with out stopping everything ?

  2. #2
    r3plica's Avatar
    r3plica is offline VB.NET Forum Enthusiast r3plica done a little coding in his/her time r3plica done a little coding in his/her time r3plica done a little coding in his/her time
    .NET Framework
    .NET 3.5
    Join Date
    Mar 2010
    Age
    30
    Posts
    81
    Reputation
    63

    Default

    it all depends on what you are trying to do, without seeing some code, it is difficult to know what you require... But an example of how to carry on when running into errors is simple.

    Here is an example of something you might do

    Code:
    
    
        Private Sub MainCodeToExecute()
            If ConnectToExternalProgram() Then
                ' Do whatever it is you needed to do
            End If
    
            ' Code that you execute regardless
        End Sub
    
        Private Function ConnectToExternalProgram() As Boolean
            Try
                ' Code to connect to external program
    
                Return True
            Catch
                Return False
            End Try
        End Function
    Basically by putting my try catch block in a seperate function and handle any errors that might occur and the main Sub will continue executing regardless.

    I hope this is what you meant.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

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