Solved

Ignore caps or non caps

Posted on 2002-06-28
6
485 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

705 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

20 Experts available now in Live!

Get 1:1 Help Now