Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Word search


Word search

Author
Message
Amerigo
Amerigo
Forum God
Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)Forum God (2.2K reputation)

Group: Forum Members
Posts: 12, Visits: 22
My program is going through each word in a story looking for names. I am using the following function to check against a string full of names (aaron, adam, ...) to see if the word is a name, but it is returning true for partial word matches such as "the" in "Theodore". What am I doing wrong?

Public Function WordExists(ByVal searchString As String, ByVal findString As String) As Boolean
    Dim returnValue As Boolean = False  
 If System.Text.RegularExpressions.Regex.Matches(searchString, "\b" & findString & "\b").Count > 0 Then returnValue = True  
 Return returnValue 
End Function


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
 If WordExists(NameList, TextBox2.Text) = True
Then    MsgBox("Yep!")  
 Else    MsgBox("Nope!")  
 End If 
End Sub

Thank you for your help!

Anyone who does not wonder is either omnipotent or a fool.

AmerigoWare
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search