Solved

Ignore caps or non caps

Posted on 2002-06-28
6
506 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 50 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Technology Partners: 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 trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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
Course of the Month11 days, 18 hours left to enroll

623 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