Solved

Ignore caps or non caps

Posted on 2002-06-28
6
492 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now