-
Mar 18th, 2023, 06:24 AM
#1
Thread Starter
Junior Member
I want to scan row and give msgbox if equal. Excuse me?
I have a project. I want it to give a warning if it finds any word from the lines in a text in other content. How can I do that? So it will do a kind of search, but it will scan the lines. For example;
Code:
Dim Text_1 As String = "VbForums
csForums
GlobalForums
JaForums
DeForums
EliteForums"
Dim Text_2 As String
Public Sub Scan_Text()
Find_Text = Text_2
If Text_1.Scan = Text_2 Then
Msgbox("Find Text")
End If
End Sub
-
Mar 18th, 2023, 10:02 AM
#2
Re: I want to scan row and give msgbox if equal. Excuse me?
If I understand well: if you find any of the word of text_1 in text_2, you have a warning ?
first, don't use a string for Text_1 but a list (of string) to store you "warning words"
after it's pretty easy :
Code:
Dim text_2 As String = "this sentence has 2 forbiden words : csForums and DeForums"
Dim Text_1 As New List(Of String) From {{"VbForums"}, {"csForums"}, {"GlobalForums"}, {"JaForums"}, {"DeForums"}, {"EliteForums"}}
For Each word As String In Text_1
If text_2.Contains(word) Then
MessageBox.Show("warning, the sentence contains the word : " & word)
End If
Next
Last edited by Delaney; Mar 18th, 2023 at 06:50 PM.
Reason: typo
The best friend of any programmer is a search engine 
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
-
Mar 18th, 2023, 03:30 PM
#3
Thread Starter
Junior Member
Re: I want to scan row and give msgbox if equal. Excuse me?
 Originally Posted by Delaney
If I understand well: if you find any of the word of text_1 in text_2, you have a warning ?
first, don't use a string for Text_1 but a list (of string) to store you "warning words"
after it pretty easy :
Code:
Dim text_2 As String = "this sentence has 2 forbiden word : csForums and DeForums"
Dim Text_1 As New List(Of String) From {{"VbForums"}, {"csForums"}, {"GlobalForums"}, {"JaForums"}, {"DeForums"}, {"EliteForums"}}
For Each word As String In Text_1
If text_2.Contains(word) Then
MessageBox.Show("warning, the sentence contains the word : " & word)
End If
Next
Thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|