Search code examples
vb.netvisual-studioif-statementcase-sensitiveignore-case

Ignore case in IF comparision


Is there an easy way to do this comparision with ignorecase ON?

If file.Extension = ".Lnk" Then MsgBox(file.Extension)

What i'm trying to do is to get all the ".lnk" or ".LNK" or ".lNk" or " ".Lnk" etc...

I know this is possibly with RegEx but... there's an easy way for that example?

Thankyou for read


Solution

  • Convert the extension to lowercase using ToLower and then compare

    If file.Extension.ToLower = ".lnk" Then MsgBox(file.Extension)
    

    And forget Regex for this. It's really overkill and inappropriate