所有编程语言在实际开发中都会出现一些异常,编程人员在代码编写时也会考虑到这些异常的出现做出相应的处理。在VB.NET里,同样需要进行一些异常处理。我们在这里就先为大家介绍一下VB.NET异常迭代捕捉的相关方法。
VB.NET异常迭代捕捉代码示例:
- Dim a As Integer = 10
- Dim b As Integer = 20
- Dim c As Integer = 10
- Dim i As Integer
- Dim liu As Integer
- Dim aaa As New System.Text.StringBuilder
- Try
- For i = 0 To 20
- If b < 10 Then aa = a + 1
- Try
- liu = (b / (a - c))
- aaa.AppendLine("ok:" & b.ToString)
- Exit For
- Catch ex As Exception
- aaa.AppendLine("error:" & b.ToString)
- bb = b - 1
- If b < 15 Then
- Throw New Exception("error")
- End If
- End Try
- Next
- Me.TextBox1.Text = aaa.ToString
- Catch ex As Exception
- MsgBox("oooo")
- End Try
- MsgBox(b.ToString)
- MsgBox("www")
VB.NET异常迭代捕捉的相关代码编写方法就为大家介绍到这里。
【编辑推荐】