Testing if a string is Ucase or not

  • Thread starter Thread starter Scotty
  • Start date Start date
S

Scotty

Hi,
Can anybody tell me how to test if a string is Uppercase (Ucase) or
not ?

The functions Ucase and LCase only seem to convert a supplied string
and not actually test them.

Hoping someone knows !...

Scotty
 
Scotty said:
Hi,
Can anybody tell me how to test if a string is Uppercase (Ucase) or
not ?

The functions Ucase and LCase only seem to convert a supplied string
and not actually test them.

If InStr(1, StringVar, UCase(StringVar), vbBinaryCompare) > 0 Then...

The above tests to see if the unaltered string is found within the same
string forced to all caps and the vbBinaryCompare does the test in a
case-sensitive manner. If InStr returns a value other than zero then the
original string was in all caps, otherwise it was not.
 
Scotty said:
Hi,
Can anybody tell me how to test if a string is Uppercase (Ucase) or
not ?

The functions Ucase and LCase only seem to convert a supplied string
and not actually test them.

Hoping someone knows !...

Scotty

If StrComp(MyString, UCase(MyString), vbBinaryCompare) = 0 Then
' MyString is upper case
Else
' MyString is mixed or lower case
End If
 
Back
Top