Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Ignore caps or non caps

Posted on 2002-06-28
6
Medium Priority
?
512 Views
Last Modified: 2010-05-18
 hi experts
   i want to know how to make a textbox ignore caps or non caps
   example
    if i write
     if text1.text="red"then
     text2.backcolor= vbred
    now if i write red only then i will get the
 result how can i get the same result by writing
 RED or Red or rED.
 i will be really thankful if u answer me.
0
Comment
Question by:HIKER
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 7117305
Hi HIKER,

use something like

if lcase(text1.text) ="red"then text2.backcolor= vbred

HAGD:O)Bruintje
0
 
LVL 14

Accepted Solution

by:
mcrider earned 200 total points
ID: 7117329
Try this:

If UCase$(Text1.Text) = "RED" Then Text2.BackColor= VBRed

That way, whatever the case typed in will be converted to uppercase before the "IF" comparison.


Cheers!®©
0
 
LVL 15

Expert Comment

by:ameba
ID: 7117341
Hi, all

Use StrComp with compare set to vbTextCompare:
   If StrComp(text1.text, "red", vbTextCompare) = 0 then
        ' strings are the same

or just add this line to declarations section:

Option Compare Text
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:rspahitz
ID: 7117511
Or intercept the keystrokes and force them to either upper or lower case in the KeyPress event or the Change event.  If you don't want the actual etxt to appear in upper/lower case, you could also transfer the upper/lower-cased version into either the tag property or a separate module-level variable.

It all depends on where you prefer to do the bulk of your overhead: on entry (as with my idea), or in the processing portion (as with the previous comments.)
0
 

Author Comment

by:HIKER
ID: 7117570
   
    works for me
0
 
LVL 14

Expert Comment

by:mcrider
ID: 7122850
Thanks! Glad I could help.

Cheers!®©
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question