Solved

Case Sensitive Text

Posted on 2000-02-16
10
245 Views
Last Modified: 2010-05-02
I need an input (namely Text1) to not be case sensitive. How do I do this?
0
Comment
Question by:R_N_WARD
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2528257
What do you mean exactly?

Generally, you don't check user inputs but you convert it when comparing.

For example:
   if "TEST" = ucase$(trim$(text1.text)) then
      msgbox "Strings are the same!!!"
   else
      msgbox "Strings are different!!!"
   endif
0
 

Author Comment

by:R_N_WARD
ID: 2528284
My program is a guessing game.  The  user types in what they think the answer is.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2528329
Dim sAnswer as String

sAnswer = UCase(Text1.Text)
If sAnswer = "THE ANSWER" Then
 MsgBox "You've Won a Million Dollars"
End If
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 32

Expert Comment

by:Erick37
ID: 2528340
Erick37 changed the proposed answer to a comment
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 50 total points
ID: 2528342
You can use exactly what I gave you.

You can also use INSTR to verify if your word is in the user's response like this:
if InStr(1, UCase$(trim$(text1.text)), "Your Answer") > 0 then
   msgbox "Good answer"
endif

0
 
LVL 3

Expert Comment

by:MTroutwine
ID: 2528347
I would suggest comparing the text using the StrComp function. Here is how to test its usage:

Create a new project add a textbox and a command button.  Paste this code in:

Private Sub Command1_Click()
    If TextDiff(Text1.Text) <> 0 Then
        MsgBox "You have not entered a matching value!"
    Else
        MsgBox "It's a match!"
    End If
End Sub

Private Function TextDiff(InputText As String) As Integer
   
    TextDiff = StrComp(InputText, "No", vbTextCompare)
   
End Function

:>)
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2528349
Why do you offer Eric37 to answer when he says exactly what I said before?
0
 
LVL 3

Expert Comment

by:MTroutwine
ID: 2528358
I should mention that the "No" in StrComp is the string you are trying to match!

:>)
0
 

Author Comment

by:R_N_WARD
ID: 2528365
Excellent answer, emoreau.  Thank you. My program works now.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2528383
emoreau:
The message
"Erick37 changed the proposed answer to a comment"
was generated by EE when I withdrew my proposed answer.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
using Access 8 68
MS Access Search and Replace Using VBA 6 71
Send outlook email from VBS Script 2 29
how to Classify of email (pdf attachments) 7 36
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

773 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