Private Sub Command1_Click()
Command1.Caption = UpperCase(Text1.Text)
End Sub
Private Function UpperCase(ByVal str As String) As Boolean
UpperCase = InStr(1, str, UCase$(str), vbBinaryCompare)
End Function If you choose to battle wits with the witless be prepared to lose.
Hm I don't think so, but very easy to write one. All you need to do is to convert the string to upper case and compare it to the original using strComp, ensuring you select the vbBinaryCompare option. (the vbTextCompare compares the text ignoring case, which you don't want!)
That should be enough to help you, but let me know if you need more....
I couldn't find a vb function, but you could create your own. You can start with the following:
Public Function isUppercase(varString As String) As Boolean
Dim bTemp As Boolean
Dim sTemp As String 'This holds the character that we are
'currently checking.
bTemp = True
Dim iLoop As Integer
For iLoop = 1 To Len(varString)
sTemp = Mid(varString, iLoop, 1)
If Asc(sTemp) < 65 Or Asc(sTemp) > 90 Then
bTemp = False
Exit Function
End If
Next
isUppercase = bTemp
End Function
cdukes - your function should work provided that all of the characters in the string are in fact letters. But if you have punctuation marks and/or digits, then your function will fail.
That being said, if the question is in fact, Are all letters within the string uppercase? then your function will fail. But if the real question is Does the string only contain uppercase letters?, then your function should be ok.
What I don't understand, if why can't you simply do the following statement:
Dim IsAllUpper as Boolean
IsAllUpper = (UCase(str) = str)
Good Luck
-------------- As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.