Posted by: Sourav | August 25, 2016

Custom Exception in VB,VB Teacher Sourav,Kolkata 09748184075


Option Strict On
Option Explicit On
Imports System
Imports System.Runtime.Serialization

Module Module1

Sub Main()
Try
Throw New loggedin(“hello I am custom exception”)
‘ Throw New loggedin
Catch ex As loggedin
Console.WriteLine(ex.Message)

Finally
Console.ReadLine()
End Try
End Sub

End Module
<Serializable()>
Public Class loggedin
Inherits Exception
Public Sub New(ByVal msg As String)
MyBase.New(msg)

End Sub
Public Sub New()
MyBase.New()

End Sub

Public Sub New(ByVal msg As String, ByVal innerexception As Exception)

MyBase.New(msg, innerexception)

End Sub
Public Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)

MyBase.New(info, context)

End Sub
End Class

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: