Monday, 12 March 2012

vb.net string split() ?


How to string split() in vb.net?
I this tutorial you can learn how to split string (split the string between two words)
Syntax:
String.split(“”)
Ex: str = string.char(hello this vb.net prrogram)
It will returns “hello”,” this”,” vb.net”,” prrogram”
 To do this program following steps to be followed
Step1:
Open Microsoft visual studio 2010 or any older version also may differ commands
Step2:
Open file new project(ctrl+shift+n)àselect windows form applicationà rename as you wish
Step3:
Drag and drop one label, textbox, and one button
Label1.textà1st string
Buttonàcheck
Step4:
Copy and paste the following code
Public Class Form1
    Private SubButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click

        Dim st_strng As String = TextBox1.Text
        Dim strArr() As String
        Dim count As Integer

        strArr = st_strng.Split(" ")
        For count = 0 TostrArr.Length - 1
            MsgBox(strArr(count))
        Next

    End Sub
End Class
 Output:

No comments:

Post a Comment