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
  • 41,827
  • 6
  • 83
  • 95
Tim Schmelter
  • 429,027
  • 67
  • 649
  • 891
0

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

If GhostTextBox1.Text.ToLower() = "buster3636" ...
Paul Grimshaw
  • 17,174
  • 6
  • 36
  • 58