0

My problem is I want to block people from putting certain names. Currently I was putting an if statement. The thing is they can simply change the lowercase letter to A Upper-case letter and then they'd be able to use the name But with an Uppercase B. How can I make it so they can't use the same characters in a row, So it wouldn't matter if they made it a lowercase b or an Uppercase B

Private Sub GhostButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GhostButton1.Click

    Try
        DownloadResponse = GetResponse.DownloadString("http://Example.com/target=" & GhostTextBox1.Text)
        FormatResponse = DownloadResponse.Split(New Char() {ControlChars.Lf}, StringSplitOptions.RemoveEmptyEntries)
        RichTextBox1.Text = FormatResponse(0)
        If GhostTextBox1.Text = "buster3636" Then RichTextBox1.Text = "You can not put this name"

2 Answers2

2

Use StringComparison.OrdinalIgnoreCase in Equals

If GhostTextBox1.Text.Equals("buster3636", StringComparison.OrdinalIgnoreCase) Then
    RichTextBox1.Text = "You can not put this name"
End If

If one or both could also be Nothing which could cause a NullReferenceException i would prefer:

StringComparer.OrdinalIgnoreCase.Equals(GhostTextBox1.Text, "buster3636") 
Jim Lewis
  • 43,505
  • 7
  • 82
  • 96
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
0

A simple way would be to use ToLower(...):

If GhostTextBox1.Text.ToLower() = "buster3636" ...
Paul Grimshaw
  • 19,894
  • 6
  • 40
  • 59