用VB.net中的Try-Catch替换Resume

时间:2018-02-01 15:39:13

标签: vb.net error-handling try-catch

我有一个代码块,如下所示,需要更改它以尝试catch。

 Private test(a as String) 
     On Error GoTo ErrorHandler
            Dim index as String 
            Statement1
            Statement2  
    Done:
            On Error Resume Next
            Exit Sub
    ErrorHandler:
            If (a.equals("a")) Then
                Resume
            Else
                Resume Done
            End If
    End Function

我查看了官方文档 https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/resume-statement并且能够发现这可以写成:

Try
    Dim index as String 
    Statement1
    Statement2  
Catch
    If (a.equals("a")) Then 
     Resume (How do we replace this)
    End If
End Try

有人可以指导我如何替换Resume语句吗?

0 个答案:

没有答案