How to equal Strings which are typed into a textbox

  • Thread starter Thread starter kimiraikkonen
  • Start date Start date
K

kimiraikkonen

I want to ask how to accept more than "one" values typed into a
textbox...

For example:

If TextBox1.Text = "Google" Then
MsgBox("You're RIGHT", vbInformation, "Great")
Else : MsgBox("You're WRONG", vbCritical, "Bad")

The question is because VB.NET is not case sensitive as i detected
(maybe wrong, don't know), instead of "Google", i want my program
accept also "gOOgle" or "GOOGLE" or "GoOgGLe"....

How to declare equality or these type of strings?

Thanks.
 
Try using "ToUpper"

Example
If TextBox1.Text.ToUpper = "GOOGLE" Then











- Show quoted text -

Matt,
Your advise is worked for uppering cases thanks but,

how to create a OR instance for strings? For example "Or" cannot be
used for strings,may be used just for Booleans as i got, i received
errors.

So, how to make my program accept "GOOGLE" and "YAHOO" or "LYCOS"
together??? When one of them is entered, i want not to have any
problem...
 
kimiraikkonen said:
I want to ask how to accept more than "one" values typed into a
textbox...

For example:

If TextBox1.Text = "Google" Then
MsgBox("You're RIGHT", vbInformation, "Great")
Else : MsgBox("You're WRONG", vbCritical, "Bad")

The question is because VB.NET is not case sensitive as i detected
(maybe wrong, don't know), instead of "Google", i want my program
accept also "gOOgle" or "GOOGLE" or "GoOgGLe"....

You may want to enable 'Option Compare Text' for the code file, or you may
wan to use 'String.Compare' with appropriate compare options.
 
You may want to enable 'Option Compare Text' for the code file, or you may
wan to use 'String.Compare' with appropriate compare options.

How to? Could you example it?
 
I want to ask how to accept more than "one" values typed into a
textbox...

For example:

If TextBox1.Text = "Google" Then
MsgBox("You're RIGHT", vbInformation, "Great")
Else : MsgBox("You're WRONG", vbCritical, "Bad")

The question is because VB.NET is not case sensitive as i detected
(maybe wrong, don't know), instead of "Google", i want my program
accept also "gOOgle" or "GOOGLE" or "GoOgGLe"....

How to declare equality or these type of strings?

Thanks.



With StringComparer.CurrentCultureIgnoreCase

Dim SpiderTyped = Me.TextBox1.Text.Trim
If .Compare(SpiderTyped, "Google") = 0 OrElse _
.Compare(SpiderTyped, "Yahoo") = 0 OrElse _
.Compare(SpiderTyped, "Lycos") = 0 Then
'it's one of the 3
Else
'otherwise
End If

End With

'or StringComparer.InvariantCultureIgnoreCase
 
Each item in an "Or" needs both sides of the equation - see example below to
get you started.

It seems like you're a little new to development. You might be well served
by finding a good text on introductory VB.Net programming.

Example:
If TextBox1.Text.ToUpper = "GOOGLE" Or TextBox1.Text.ToUpper = "YAHOO" Then
 
So, how to make my program accept "GOOGLE" and "YAHOO" or "LYCOS"
together??? When one of them is entered, i want not to have any
problem...
Why not use Radio buttons or a select list to allow user to choose one
 
Why not use Radio buttons or a select list to allow user to choose one

However, i managed to do this but adding "elseIf" statement, all is OK
now.

Thanks.
 
Back
Top