ARTICLE

String. Split () in vb.net

Posted by Sapna Articles | Visual Basic Language June 27, 2011
Split function analyzed string and divide string based on a certain character (such as a comma or space).
Download Files:
 
Reader Level:

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

Figure 1

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 figure 2.

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

Figure 2

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor