I VB.Net, we can use one method called "Split(space)" to split each word from the sentence or paragraph.
Below is the sample small application use split each word in Textbox to list in Listbox.
Below is the sample small application use split each word in Textbox to list in Listbox.
Application Design
No | Control Type | Name | Text |
1 | TextBox1 | TextBoxString | |
2 | ListBoxWord1 | ||
3 | Button1 | ButtonGetWord | Get Word |
Code
Public Class Split_Word
Private Sub ButtonGetWord_Click(sender As Object, e As EventArgs) Handles ButtonGetWord.Click
ListBoxGetWord.Items.Clear() ' clear old lists
Dim words() As String
Dim space() As Char = {" "c}
words = TextboxString.Text.Split(space) ' Split each word which devided by space in TextboxString
Dim word As String
For Each word In words
ListBoxGetWord.Items.Add(word) list each word in listbox
Next
End Sub
End Class
0 comments:
Post a Comment