Solved

Ignore caps or non caps

Posted on 2002-06-28
6
500 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

820 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