Public Class App
Public Shared Sub Main()
Try
DivideByTwo(7)
Catch Ex As ArgumentException
Console.WriteLine(Ex)
End Try
End Sub
Private Shared Function DivideByTwo(ByVal num As Integer) As Integer
If ((num And 1) = 1) Then
Throw New ArgumentException("Number must be even", "num")
End If
Return (num / 2)
End Function
End Class