PLz tell me how to use Split function method in VB.net

Hi there friends

i am having problem in spliting a string by the built in Split method in vb.net plz guide me and tell me the method how to use this function

Thankyou plz tell me as fast as u can

bye




Answer this question

PLz tell me how to use Split function method in VB.net

  • BryanM-NZ

    Split returns an array of strings - so you need to change the line to:

    dim splitstring() as String = sourceString.Split('' ")

    This declares splitstring as an array of strings.

    The following:

    dim sourceString as string = "This is something simple"

    dim stringItems() as string = sourceString.Split(" ")

     

    Would result in:

    stringItems(0) being "This"

    stringItems(1) being "is"

    stringItems(2) being "something"

    stringItems(3) being "simple"

    Hope this helps :)



  • Stevetrooba

    Thanks for help but on line

    dim splitstring as String = sourceString.Split('' ") // There is an error which says that

    " Value of type 1-dimensional array of string cannot be converted to String"

    Plz tell me the problem

    Thanks

    Bye



  • Navin Tripathi

    Here is a very simple example:

    Dim sourceString As String = "This is a string I wish to split into words"

    Dim arrayOfStrings() As String = sourceString.Split(" ")

    Alternatively look in the help:

    • Make sure the help is on the Index Tab
    • Make sure your help is filtered by Visual Basic (top part of the index tab)
    • Type String.Split in the 'Look for' textbox
    • Click on the String.Split method in the listbox under the 'Look for' textbox


  • PLz tell me how to use Split function method in VB.net