VB.NET Split String - NET Heaven

  • Home
  • Explore
  • Tags
  • Contribute
  • Home
  • »
  • VB.NET
  • »
  • VISUAL BASIC LANGUAGE
VB.NET Split String Posted in VB.NET | VISUAL BASIC LANGUAGE on November 07, 2019 Tags: Split String, Split String in VB.NET In this article you will learn how to split string in VB.NET.
  • 6468

String class provides the Split method that is used to split a string delimited with some specified characters. It identifies the substrings that are delimited by one or more characters specified in an array, and then return these substrings in a string array. Delimiter characters are not included in the substrings.

The Split function returns one of these:

  • An array consisting of a single element containing the entire string if the string contains none of the characters in the separator list.

  • An array of substrings if the string is delimited by one or more of the characters specified in the separator list passed in the Split method.

  • An array of substrings in a string delimited by white space characters if those characters occur and the separator array passed is a null reference or contains no delimiter characters.

For example, if we want to split string 38,\n29, 57 with a character array separator list containing comma and space characters, we will get "38", "", "29", "", "57" as string array elements returned. Or, if we want to split string "38..29..57" with the character array delimiter list containing a period '.' , we will get "38", "", "29", "", "57" as string array elements. Here is a complete example of using various separators to split different strings. Module Module1 Sub Main() ' Some strings with separated by space, comma, and a substring Dim intSpacedString As String = "1 3 5 7 9" Dim charCommaString As String = " a, e, i, o, u" Dim nameCommaString As String = "Mahesh,Raj,,,Dinesh,Mike,Praveen,Joe,Lana" Dim subStringString As String = "12KKK34KKK56KKK78KKK" Dim spaceSeparator As Char() = New Char() {" "c} Dim commaSeparator As Char() = New Char() {","c} Dim stringSeparators As String() = New String() {"KKK"} Dim result As String() Console.WriteLine("=======================================") Console.WriteLine("Space separated strings :" & vbLf) result = intSpacedString.Split(spaceSeparator, StringSplitOptions.None) For Each str As String In result Console.WriteLine(str) Next Console.WriteLine("=======================================") Console.WriteLine("Comma separated strings :" & vbLf) result = charCommaString.Split(commaSeparator, StringSplitOptions.None) For Each str As String In result Console.WriteLine(str) Next result = nameCommaString.Split(commaSeparator, StringSplitOptions.None) For Each str As String In result Console.WriteLine(str) Next Console.WriteLine("=======================================") Console.WriteLine("Substring separated strings :" & vbLf) result = subStringString.Split(stringSeparators, StringSplitOptions.None) For Each str As String In result Console.WriteLine(str) Next Console.WriteLine("=======================================") Console.ReadKey() End Sub End Module

Output split1.gif

Conclusion Hope this article would have helped you in understanding Split String in VB.NET.

Related Articles

  • Split() method in VB.NET
  • VB.NET Padding Strings
  • WPF Grid Using VB.NET
  • VB.NET Split and Match Methods
  • How to Convert String to DateTime in VB.NET
  • VB.NET, Custom String Methods
  • String class in VB.NET- String.Compare method
  • Introduction of DataGrid Control in VB.NET
  • String and Math Functions in Visual Basic .NET
  • VB.NET Padding

Categories

  • ACTIVE DIRECTOTRY IN VB.NET
  • ALGORITHMS AND VB.NET
  • ARRAY IN VB.NET
  • ASP.NET AJAX IN VB.NET
  • ASP.NET USING VB.NET
  • ASSEMBLIES IN VB.NET
  • COM INTEROP IN VB.NET
  • CRYPTOGRAPHY IN VB.NET
  • CRYSTAL REPORTS IN VB.NET
  • DATABASE & DBA
  • DEPLOYMENT IN VB.NET
  • DESIGN & ARCHITECTURE
  • DIRECTX WITH VB.NET
  • ENTERPRISE DEVELOPMENT
  • FILE IN VB.NET
  • GAMES IN VB.NET
  • GDI+ IN VB.NET
  • GENERAL
  • LINQ WITH VB.NET
  • MOBILE DEV IN VB.NET
  • MULTITHREADING IN VB.NET
  • NETWORKIN WITH VB.NET
  • OFFICE AND VB.NET
  • PRINTING IN VB.NET
  • REMOTING IN VB.NET
  • REPORTS IN VB.NET
  • SECURITY IN VB.NET
  • SILVERLIGHT USING VB.NET
  • Speech in VB.NET
  • STRING IN VB.NET
  • TABLET PC
  • VB.NET ADO.NET
  • VB.NET ARTICLE
  • VB.NET EXCEPTION HANDLING
  • VB.NET FAQ
  • VB.NET HOW DO I
  • VB.NET LANGUAGE
  • VB.NET TUTORIALS
  • VB.NET WINDOWS SERVICES
  • VBA
  • VISUAL BASIC 10
  • VISUAL BASIC LANGUAGE
  • WCF WITH VB.NET
  • WEB CONTROL IN VB.NET
  • WEB DEV IN VB.NET
  • WEB FORM WITH VB.NET
  • WEB SERVICES IN VB.NET
  • WINDOWS CONTROLS
  • WINDOWS FORMS IN VB.NET
  • WORKFLOW IN VB.NET
  • WPF IN VB.NET
  • XAML IN VB.NET
  • XML IN VB.NET

More Articles

  • Algorithm Generate Fibonacci Series in VB.NET
  • Algorithm - Factorial of an Number in VB.NET
  • Algorithm Quadrant in VB.NET
  • Algorithm Circular Queue in VB.NET
  • Algorithm Queues in VB.NET
  • Algorithm Stack in VB.NET
  • Algorithm Concept in VB.NET
  • How to use .NET Assemblies in VB.NET
  • How to create assembly in VB.NET
  • VB.NET Create Instance of a Type Dynamically
  • Select and Delete Ink in Tablet PC in VB.NET
  • Using Tablet PC Ink on Windows Controls in VB.NET
  • Tablet PC Frequently Asked Question in VB.NET
  • Setting Ink Overlay Properties in Tablet PC in VB.NET
  • VB.NET Advanced Controls of Mobile Internet
  • MediaElement control in Windows Phone 7
  • Image Brush Background set in Windows Phone 7
  • Mobile Mail sending Application in ASP.NET using VB.NET
  • Mobile Banking Application in ASP.NET using VB
  • I-MODE Client and Mobile Programming in VB.NET
  • Basic User Interface Controls of Mobile Internet in VB.NET
  • Basics of the Mobile Internet Toolkit using VB.NET
  • A glance at .NET Framework 3.0 in VB.NET
  • Reflection in VB.NET
  • Custom Exception Handling in VB.NET
  • Exception Handling in VB.NET
  • Inheritance in VB.NET
  • Retrieving Environment Variables in VB.NET
  • Introduction of Visual Studio 2008 in VB.NET: Part 1
  • VB.NET Select statement in SQL query
  • Dialog Box in VB.NET
  • Windows Registry in VB.NET
  • Get Current Time Zone in VB.NET
  • VB.NET Balloon Tooltip
  • Binding a ComboBox in VB.NET
  • Image as Button Background in VB.NET
  • Button State in VB.NET
  • Operating System Version in VB.NET
  • How many users are using the site at a same time?
  • BorderThickness Value in WPF
  • VB.NET display data in the FormView control
  • Add Web Server Controls to a PlaceHolder control at run time
  • DropDownList control through data binding in VB.NET
  • DropDownList control that contains items in VB.NET
  • How do I open a URL in a new Browser Window in ASP.NET?
  • Display an XmlNode contents in a DataGrid?
  • Delete a directory in VB.NET
  • Create and Save Bitmap Image in VB.NET?
  • VB.NET Constants
  • Variables in VB.NET
© 2020 DotNetHeaven. All rights reserved.
  • TERMS & CONDITIONS
  • |
  • CONTACT US
  • |
  • REPORT ABUSE

Từ khóa » Visual Basic String Array Split