Exception Handling in VB.net
Source Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Dim str As String = TextBox1.Text
Try
If (TextBox1.Text = "") Then
Throw (New exc("Empty Values"))
Else
MsgBox(TextBox1.Text)
End If
Catch ex As exc
MsgBox(ex.Message)
End Try
End Sub
End Class
Public Class exc : Inherits ApplicationException
Sub New(ByVal msg As String)
MyBase.New(msg)
End Sub
End Class
Comments
Post a Comment