title: How can I specify that the value of a variable in VBscript be case insensitive?
body: <p>Part of a VBscript I'm writing inside of an HTA calls for the user to type a name into a text box which will generate a folder with that name. I am building checks into the script to make sure that no illegal characters or names are used. Where I am getting stuck at is trying to make sure that if a user enters COM1 or LPT1 they will be told that the name they tried to use is not allowed instead of getting a script error. The problem is I can't figure out how to do it without writing an If statement for every possible way the letters in COM1 through COM9 and LPT1 through LPT9 could be arranged in different cases (e.g. com1, Com1, cOm1, etc.). The code snippet below shows what I mean.</p>
  
  <pre><code>sFldrName = BasicTextbox.Value
  sFldrBadMsg = "You've chosen an illegal folder name."
  
  If sFldrname = "COM1" Then
    Msgbox  sFldrBadMsg
  ElseIf sFldrname = "COM2" Then
    Msgbox  sFldrBadMsg
  ElseIf sFldrname = "COM3" Then
    Msgbox  sFldrBadMsg
  </code></pre>
  
  <p>In the above example whatever the user enters into the text box is assigned to "sFldrname". Then the script checks whether the string assigned "sFldrname" is COM1 or COM2 or COM3. The problem is I can only check for those strings in the exact case specified. If the user enters COM1 they will get my warning message. But, if they enter com1 (all lower case) or CoM1 (mixed case) they will get a script error because it is still an illegal name regardless of case. In order to account for this with the method I used above I would have to do something like this:</p>
  
  <pre><code>sFldrName = BasicTextbox.Value
  sFldrBadMsg = "You've chosen an illegal folder name."
  
  If sFldrname = "COM1" Then
    Msgbox  sFldrBadMsg
  ElseIf sFldrname = "Com1" Then
    Msgbox  sFldrBadMsg
  ElseIf sFldrname = "COm1" Then
    Msgbox  sFldrBadMsg
  ElseIf sFldrname = "cOm1" Then
    Msgbox  sFldrBadMsg
  ElseIf sFldrname = "coM1" Then
    Msgbox  sFldrBadMsg
  ElseIf sFldrname = "cOM1" Then
    Msgbox  sFldrBadMsg
  ElseIf sFldrname = "CoM1" Then
    Msgbox  sFldrBadMsg
  ElseIf sFldrname = "com1" Then
    Msgbox  sFldrBadMsg
  </code></pre>
  
  <p>And I would have to do that for COM2 through COM9 and LPT1 through LPT9 as well. I really don't want to have to do that. So, when I am checking the value of "sFldrname" to see what string it is, is there a way to ignore the case of that string? Or, is there a better way altogether to go about doing what I am trying to do? Thanks.</p>