We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,524 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Upper and lower case sensitive

I'm currently creating a program where a user should enter the correct color shown in it. This should be entered in text box. What code should I use to make the program accept both upper case and lower case text inputs? For example "red" should be equivalent to "Red" something like that. My code is below please help me guys

If Text1.Text = "Red" And Label4.BackColor = vbRed Then
score = score + 1
Label6.Caption = score
End If
4
Contributors
4
Replies
21 Hours
Discussion Span
8 Months Ago
Last Updated
6
Views
Question
Answered
angel06
Newbie Poster
24 posts since Aug 2012
Reputation Points: 12
Solved Threads: 0
Skill Endorsements: 0

Use UCase() or LCase () function. all string will be converted to upper or lower string

If UCase(Text1.Text) = UCase("red") And Label4.BackColor = vbRed Then
    score = score + 1
    Label6.Caption = score
End If

or if you just want to make uppercase the first string

mystring = Text1.Text
If (UCase(Left(mystring, 1)) & Right(mystring, Len(mystring) - 1)) = "Red" Then
    score = score + 1
    Label6.Caption = score
End If
Jx_Man
Senior Poster
3,538 posts since Nov 2007
Reputation Points: 1,488
Solved Threads: 524
Skill Endorsements: 64

Thanks for the help man! Cheers!

angel06
Newbie Poster
24 posts since Aug 2012
Reputation Points: 12
Solved Threads: 0
Skill Endorsements: 0

Hi,

or else, LostFocus of Text1, write this code:

Text1.Text = StrConv(Text1.Text, vbProperCase)

and check for "Red"

Regards
Veena

QVeen72
Veteran Poster
1,017 posts since Nov 2006
Reputation Points: 118
Solved Threads: 164
Skill Endorsements: 5

What if i am partially color blind and red appears maroon or saffron to me. Does this concept of typing the name of the color in the code work ?

Just a thought, though. :)

debasisdas
Posting Genius
6,968 posts since Feb 2007
Reputation Points: 722
Solved Threads: 457
Skill Endorsements: 20
Question Answered as of 8 Months Ago by QVeen72, debasisdas and Jx_Man

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.5360 seconds using 2.76MB