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

#### ScottNiag

##### Active Member
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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Just convert the string to upper case using ucase.

ucase("hi") would return "HI"

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?

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.

How about doing something a lot easier?

If ucase(string)=string then...

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.

Surely you do not need to compare each letter:

If EnteredString = Pwd then

End if

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.

Replies
2
Views
261
Replies
1
Views
365
Replies
2
Views
372
Replies
1
Views
729
Replies
3
Views
281

1,218,845
Messages
6,144,801
Members
450,567
Latest member
Mplz

### 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.

### Which adblocker are you using?

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

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