Mega Code Archive

 
Categories / VB.Net Tutorial / Data Type
 

Catch Exception for String Substring

public class Test    public Shared Sub Main         Dim strCaption As String         strCaption = "Answer"         Try             Console.WriteLine(strCaption.Substring(10, 1))         Catch ex As Exception             Console.WriteLine(ex.Message)         End Try    End Sub End class startIndex cannot be larger than length of string. Parameter name: startIndex