Results 1 to 5 of 5

Thread: [RESOLVED] [2005] Word and number filter

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    364

    Resolved [RESOLVED] [2005] Word and number filter

    hello,
    I am trying to filter 2 things:
    1) a username, if the username contains two numbers at the begining of the username then do something

    2) look at a string of text if the text contains certain words then do something

    I have had a search around and have found filters but they replace the words, if anyone can offer any help that would be great


    many thanks
    Richard <><

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: [2005] Word and number filter

    To validate username:
    VB Code:
    1. Private Function ValidUserName(ByVal UserName As String) As Boolean
    2.         Dim reg As New System.Text.RegularExpressions.Regex("\d{2}\w+")
    3.         Dim M As System.Text.RegularExpressions.Match = reg.Match(UserName)
    4.         Return M.Success
    5.     End Function

    To look for a specific string
    VB Code:
    1. If text.IndexOf("SearchString") <> -1 Then
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    364

    Re: [2005] Word and number filter

    thanks ComputerJy

    for the username part, if I wanted to add a msgbox saying username valid if where would I place it.

    thanks
    Richard <><

  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: [2005] Word and number filter

    VB Code:
    1. Private Sub UserNameEntered(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         If ValidUserName(UserNameTextBox.Text) Then
    3.             MessageBox.Show("Valid Username")
    4.         End If
    5.     End Sub
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    364

    Re: [RESOLVED] [2005] Word and number filter

    thanks very much
    Richard <><

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width