Substring in Vb.Net String Class
By: Issac
Substring is an interesting method of string class it returns a string that is a substring of the given string. It begins from a given index and extends up to the specified length
Public Function Substring (ByVal startIndex As Integer, ByVal length As Integer) As String
Parameters:
startIndex: The index of the start of the substring.
length: The number of characters in the substring.
Returns:
The specified substring.
Exceptions:
System.ArgumentOutOfRangeException : the beginIndex or length less than zero, or the begin index + length not within the specified string
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim str As String
Dim retString As String
str = "This is substring test"
retString = str.Substring(8, 9)
MsgBox(retString)
End Sub
End Class
When you run this program, in the message box it will display "subtring"
Archived Comments
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Using Resume Next and Resume Line in VB.net
Using On Error GoTo 0 in VB.net
Getting an Exception's Number and Description in VB.net
Raising an Exception Intentionally in VB.net
Exception Filtering in the Catch Block in VB.net
Using Multiple Catch Statements in VB.net
Throwing an Exception in VB.net
Throwing a Custom Exception in VB.net
Changes in Controls from VB6 to VB.net
Unstructured Exception Handling in VB.net