Input Box - UPPERCASE lowercase

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to have a InputBox ignore the case?

CHAIR = chair = Chair = ChAiR = etc......
 
Hi Alex,

Dim sStr

sStr = LCase(Application.InputBox("Type something"))
MsgBox sStr
 
If you are talking about a logical test such as

If "Chair" = "chair" Then

you can place the following statement at the top of your module

Option Compare Text

This makes text comparisons non case sensitive.

Alternatively, you can use the following

If Upper(X) = Upper(Y) Then
 
res = InputBox("Enter word")
res = lcase(res)
' or res = Ucase(res)

or if you are testing

if lcase(res) = "chair" then
 
Actually I just want the Inputbox to ignore whatever case is entered and just
take it for what it is.

So I don't have to have every possible combination listed in a IF statement...
 
I tried this... but it just exited out....

Norman Jones said:
Hi Alex,

Dim sStr

sStr = LCase(Application.InputBox("Type something"))
MsgBox sStr
 
I'm messing around to get a better understanding of InputBoxes and IF
statements and thier it's limits...

Here's what I put together....

Dim tea As String

More:

tea = LCase(Application.InputBox("Please enter a tea beverage", "Tea Guide"))
If tea = "" Then
Exit Sub
ElseIf tea = "Chai" Then
MsgBox ("Good Tea, try something else")
GoTo More
ElseIf tea = "Green" Then
MsgBox ("Great Tea, try something else")
GoTo More
ElseIf tea = "Black" Then
MsgBox ("Better Tea, try something else")
GoTo More
ElseIf tea = "Herbal" Then
MsgBox ("BEST TEA!!!")
Else: tea = vbCancel
Exit Sub
End If
 
You forgot to say none of those work unless you did

Option Compare Text

at the top of the module

If you convert tea to lower case, then it can't match a string that contains
upper case.

You should change your hard coded values to all lower case, such as Chai to
chai, Black to black, etc
 
As you have converted your input to lower case, you must use lower case in
all your comparisons. For example

ElseIf tea="chai" Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top