' Visual Basic .NET Document Option Strict On ' Imports System.Runtime.CompilerServices Public Class ErrorClass Dim msg As String Public Sub New(errorMessage As String) msg = errorMessage End Sub Public ReadOnly Property Message As String Get Return msg End Get End Property End Class Public Module StringUtilities Public Function SplitString(value As String, index As Integer) As String() If index < 0 Or index > value.Length Then Dim BadIndex As New ErrorClass("The index is not within the string.") Throw BadIndex End If Dim retVal() As String = {value.Substring(0, index - 1), value.Substring(index)} Return retVal End Function End Module ' Compilation produces a compiler error like the following: ' Exceptions1.vb(27) : error BC30665: 'Throw' operand must derive from 'System.Exception'. ' ' Throw BadIndex ' ~~~~~~~~~~~~~~ ' Module Example Public Sub Main() End Sub End Module