Split() method in VB.NET

Split function analyzed string and divide string based on a certain character (such as a comma or space).
  • 4790
 

Split function analyzed string and divide string based on a certain character (such as a comma or space). Certain character is an optional delimiter character that identifying the string. By default, space "  "c assume as a delimiter. It returns and stores a zero based, one-dimensional array containing a specified number of substrings.

img.GIF

In below code, I am using Split function to show you how its work first code replace blank space " " c with and in second code it's replaced by vbLf see below image.

Code

Imports System.Globalization
Imports System.Threading
Module
Module1
    Sub Main()
        Dim split As String()
        Dim value As String
        Dim info As CultureInfo = Thread.CurrentThread.CurrentCulture
        Dim text As TextInfo = info.TextInfo
        Console.WriteLine("Enter your Name and Address. ")
        value = Console.ReadLine()
        Console.WriteLine()
        split = value.Split(" "c)
        Console.WriteLine(text.ToTitleCase(split(0)) & "." & text.ToTitleCase(split(1)))
        Console.Write(vbLf & "Name :" & text.ToTitleCase(split(0)) & vbLf & "Address :" & text.ToTitleCase(split(1)))
        Console.ReadLine()
    End Sub
End Module

Output

2.gif

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.