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

Recommended Answers

All 5 Replies

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


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("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

what does keys.return means ? Sorry because I'm a beginner in programming

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.