Register | Sing In

New posts

Stacks in C programming Linked Lists in C programming File Input/Output in C programming Check prime numbers in C Programming C Programming Enumeration C Programming Union

Archives

2013-10 2013-09 2013-08

VB.net Split String

August 25, 2013 Posted by: GPA Views: 920 2 comments

Task

How to split string? Parse string and return a list of all the words it contains.

Solution

To solve this problem we can use method Split of Class String.

The Split method divides the string in seperate words if delimiters is found in string, and it returns the result as an array of strings. 

For this example we select  space delimiter " ". We loop loop over the Strings and display each words to the Console.

  

Module SplitMethod
Sub Main()
     Dim input_String As String = "Globalproganswer.com include question & answers of all programming languages like Ajax, ASP"
     Dim separators() As Char = {" "c} 'Split string based on spaces
     Dim output_Words() As String
     ' Split the input string.
     output_Words = input_String.Split(separators)
     Dim count As Integer = 0
     'show result
     For Each Word As String In output_Words
         Console.WriteLine(count.ToString() & ": " & Word)
         count += 1
         Next
     Console.ReadLine()
    End Sub
End Module

Output:

split String vb.net example

2 Comments...

1. John

June 12, 2013, 11:18 am
Avatar
Good material

2. Bred

June 5, 2013, 9:06 am
Avatar
Good material
Leave a Reply

Please, Sing In to leave a Reply for this material.



Online Chat

LiveZilla Live Help

Popular posts

Function strtok in C programming Check prime numbers in C Programming C Programming Union Linked Lists in C programming File Input/Output in C programming C Programming Enumeration

RSS-subscribe

New materials

Subscribe