Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Case Sensitive Text

Posted on 2000-02-16
10
Medium Priority
?
252 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
[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
  • 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
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!

 
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 200 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…
Suggested Courses

688 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