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
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
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
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.
refer to the solution provided to this thread https://www.daniweb.com/software-development/vbnet/threads/451831/how-can-i-make-this-tracking-be-on-it-own-and-not-track-other-fields
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.