Getting the case (upper or lower) of a string character in V

ScottNiag

Active Member
Joined
Sep 3, 2002
Messages
260
Hi. I am trying to learn VBA for Excel from a textbook at home. I have MOUS Excel expert. I am wasting huge amounts of time trying to find the answers to niggling liitle problems that seem to continually stuimp me.

I am currently doing an exercise where a user inputs a password. I store it as a string variable. The characters are all SUPPOSED to be upper case. You then have to check. There must be something which returns the CASE property of a character but I'll be darned if I can find it. Any ideas gratefully and lovingly accepted.

On a more general note, for those who have really conquered VBA - how did you learn it?
A class? Online course? Books? Just picked it up? I find that without an instructor to help out, the textbbok method is proving to be an exercise in continual frustration.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Just convert the string to upper case using ucase.

ucase("hi") would return "HI"
 
Upvote 0
No, that isn't quite it. I need to reject the password if any part of it wasn't entered as uppercase in the first place.

Ex. STUMpED

How to tell that one or more of the letters is lower case?
 
Upvote 0
How about using the worksheet function CODE, it returns the code number for each character. If the value is between 65 (A) and 90 (Z), accept that letter, otherwise it is either lowercase or non-alpha, Or how about checking to see if UCASE(password)=password? You might need to loop through all characters though. The first solution allows you to exit before you check all characters once you find an invalid value.
 
Upvote 0
zace - it worked, thx. I actually tried about the same thing, where I stored Ucase(variable) as another variable2, then said if variable = variable2 then... but for some reason it didn't work that way. Thx again.
 
Upvote 0
Surely you do not need to compare each letter:

If EnteredString = Pwd then

'your code

End if
 
Upvote 0
Vog

Actually the problem is more the setting up of a new pwd rather than comparing to an existing pwd. It's just an exercise in a textbook.
 
Upvote 0

Forum statistics

Threads
1,215,521
Messages
6,125,302
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top