Mid Function in VB.NET

What is Mid() function in VB.NET?

Explanation

Mid Function

Mid() in Visual Basic.net is a string function that is used to extract a copy of a character or set of characters from a string.
Syntax:

Function Mid( ByVal Str As String, ByVal Start As Integer,
Optional ByVal Length As Integer) As String

In the above syntax Str specifies the string from which the characters to be extracted from the starting position specified using Start, until the specifed Length of characters.
Example:

Module Module1
Sub Main()
Dim Str As String = "Seven Wonders of the World"
Console.WriteLine("It is a beautiful" & Mid(Str, 21, 6))
Console.ReadLine()
End Sub
End Module
Result:

It is a beautiful World

In the above example, the word 'world' is extracted from the string to write another string.

Visual Basic Tutorial


Ask Questions

Ask Question