הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Question
Saturday, March 6, 2010 11:07 AM
Hi,
I use for example:
Dim S As String = TextBox1.Text
if(S.Contains("BlaBla") Then
' ..
End If
But when I use blabla in my textbox it doesn't work..
How Can I ignore the capital letter or non-capital letter function?
Regards,
All replies (6)
Saturday, March 6, 2010 12:26 PM ✅Answered
Hi,
I use for example:
Dim S As String = TextBox1.Text if (S.Contains("BlaBla" ) Then ' .. End If
But when I use blabla in my textbox it doesn't work..
How Can I ignore the capital letter or non-capital letter function?Regards,
You can change the case of the text in the textbox before making the comparison. Change the text to either Upper or Lower case with:
Dim S As String = TextBox1.Text.ToUpper
Or with:
Dim S As String = TextBox1.Text.ToLower
Then check with:
If S.Contains("BLABLA") Then ' if you converted TextBox text to upper case
If S.Contains("blabla") Then ' if you converted TextBox text to lower case
Or you can convert and test in the same line based on which case you want to use. If you want upper case:
If S.ToUpper.Contains("BLABLA") Then
If you want lower case:
If S.ToLower.Contains("blabla") Then
:)
Doug
SEARCH ... then ask
Saturday, March 6, 2010 4:23 PM ✅Answered | 1 vote
Thanks, I know ToUpper and ToLower but what if I use B laB la? Isn't there a possibility to disable the case sensitivity..?
Regards,
You can try using Option Compare Text
** Doug
SEARCH ... then ask
Saturday, March 6, 2010 4:50 PM ✅Answered
If S.ToUpper.Contains("BLAbLa".ToUpper) ThenSuccess
Cor
Sunday, March 7, 2010 2:06 AM ✅Answered
One more preferred method is following
Dim S As String = TextBox1.Text
If "BlaBla".IndexOf(S, StringComparison.OrdinalIgnoreCase) >= 0 Then
MessageBox.Show("Exist")
End If
If you are comparing after making them same case then use ToUpper as Cor has shown instead of ToLower since ToLower does not work correctly in some situation
If you are thinking what all these means, then read
http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx
Arjun Paudel
Saturday, March 6, 2010 2:02 PM
Thanks, I know ToUpper and ToLower but what if I use B laB la? Isn't there a possibility to disable the case sensitivity..?
Regards,
Sunday, March 7, 2010 10:27 AM
Hi,
Thanks for answers, works perfect now.
Regards,