473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How to equal Strings which are typed into a textbox

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.

Aug 4 '07 #1
8 1575
Try using "ToUpper"

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

"kimiraikkonen" <ki*************@gmail.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
>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.

Aug 4 '07 #2
On Aug 5, 12:28 am, "Matt F" <mfielderREMOVEC...@nospam.nospamwrote:
Try using "ToUpper"

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

"kimiraikkonen" <kimiraikkone...@gmail.comwrote in message

news:11**********************@k79g2000hse.googlegr oups.com...
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.- Hide quoted text -

- 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...

Aug 4 '07 #3
"kimiraikkonen" <ki*************@gmail.comschrieb:
>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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Aug 4 '07 #4
On Aug 5, 12:49 am, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...@gmx.atwrote:
"kimiraikkonen" <kimiraikkone...@gmail.comschrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
How to? Could you example it?

Aug 4 '07 #5
On 4 Ago, 23:22, kimiraikkonen <kimiraikkone...@gmail.comwrote:
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

Aug 4 '07 #6
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
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...

Aug 4 '07 #7
>
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
Aug 5 '07 #8
On Aug 5, 6:47 am, "Hal Rosser" <hmros...@bellsouth.netwrote:
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
However, i managed to do this but adding "elseIf" statement, all is OK
now.

Thanks.

Aug 5 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ayende Rahien | last post by:
I've a really strange problem, in some part of my code I compare two strings (through object), and while I *know* that they equal each other, and in the watch window they do equal each other, then...
1
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number?...
2
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number?...
2
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number?...
1
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.