Solved

Case Sensitive Text

Posted on 2000-02-16
10
243 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 69

Expert Comment

by:Éric Moreau
Comment Utility
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
Comment Utility
My program is a guessing game.  The  user types in what they think the answer is.
0
 
LVL 32

Expert Comment

by:Erick37
Comment Utility
Dim sAnswer as String

sAnswer = UCase(Text1.Text)
If sAnswer = "THE ANSWER" Then
 MsgBox "You've Won a Million Dollars"
End If
0
 
LVL 32

Expert Comment

by:Erick37
Comment Utility
Erick37 changed the proposed answer to a comment
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 50 total points
Comment Utility
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
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 3

Expert Comment

by:MTroutwine
Comment Utility
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 69

Expert Comment

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

Expert Comment

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

:>)
0
 

Author Comment

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

Expert Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…

772 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

10 Experts available now in Live!

Get 1:1 Help Now