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
Domanda
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
Soluzione
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
Altri suggerimenti
Use String.Equals
for string comparisons. To ignore case use CurrentCultureIgnoreCase
or InvariantCultureIgnoreCase
.
If String.Equals("AAA", "aaa", StringComparison.InvariantCultureIgnoreCase) Then
'more code
End If
use this for ignore case compare
If String.Compare(file.Extension, ".lnk", True) = 0 Then MsgBox(file.Extension)
change true to false for case sensitive compare
Module Test
Sub Main()
Dim userString As String = Nothing
Dim finalString As String = "Jacob"
Console.WriteLine("Enter username")
userString = Console.ReadLine()
If String.Compare(finalString, userString, True) = 0 Then
Console.WriteLine("Access Granted")
Else
Console.WriteLine("Access Denied")
End If
Console.ReadLine()
End Sub
End Module