Can someone help me solve this problem:

1)How can i insert every word of label.text to array
2)How can i check if the word that i type on textbox is equal to every word on label.text

Edited 2 Years Ago by jeffersonalomia: Error on grammar

To get an array of the text:
string[] s = label.Text.Split(' ');

and to check:
if(s.Contains(checkString)) {}

To store the every words you can use this.

Dim StrArray() as string

StrArray=Split(Trim(Label1.Text),Space(1))

The following code can check the words.

Private Sub TextBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
        If e.KeyCode = Keys.Return Then
            If FindWords(Trim(TextBox1.Text)) Then
                MsgBox("Found")
            Else
                MsgBox("Not Found")
            End If
        End If
    End Sub

    Private Function FindWords(ByVal FString As String) As Boolean
        Dim Result As Boolean = False
        If StrArray.Contains(FString) Then
            Result = True
        End If

        Return Result
    End Function

Edited 2 Years Ago by Santanu Das

When you type any key on your keyboard, it supplies a unique value to the CPU, by which CPU can understand which key is pressed.

For every work system performs an event. By e we can try to know which event system performs.
Here by e.KeyCode we get the information about the key which is pressed.
Every Key has unique KeyCode. Keys.Return means you press the Enter key.
In TextBox KeyDown or KeyUp event, if you write e.KeyCode = then you can get all KeyCodes List for every keys of your keyboard.

In the above post, I introduce the TextBox KeyDown event. This event performs when you down any key of your keybord. After writing a word in the TextBox press the Enter key, it shows different message if it finds or not.

Edited 2 Years Ago by Santanu Das

This article has been dead for over six months. Start a new discussion instead.