UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> IsAllCaps    

Contents

IsAllCaps() Function

Returns a boolean value indicating whether or not the passed string contains all capital letters. Punctuation and special characters can be passed in the string and do not effect the results.

Syntax

CODE
IsAllCaps(expression)

Where expression is of type String.

CODE
Public Function IsAllCaps(strText As String) As Boolean
' A result of True indicates all the letters are capitalized.
' http://www.utteraccess.com/wiki/index.php/FunctionNameHere
' Code courtesy of UtterAccess Wiki
' Licensed under Creative Commons License
' http://creativecommons.org/licenses/by-sa/3.0/
'
' You are free to use this code in any application,
' provided this notice is left unchanged.
'
' rev  date        brief descripton
' 1.0  2013-01-26  Initial Release
'
   Const strCaps As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
   
   Dim strCurrentLetter As String
   Dim i As Long
   
   IsAllCaps = True
       
   For i = 1 To Len(strText)
       strCurrentLetter = Mid(strText, i, 1)
       If strCurrentLetter Like "[a-Z]" Then
           If InStr(1, strCaps, strCurrentLetter, vbBinaryCompare) = 0 Then
               IsAllCaps = False
               Exit For
           End If
       End If
   Next i

End Function

Return Value

Boolean.

Example

From the Immediate Window:

CODE

? IsAllCaps("HELLO WORLD!!!")
True

? IsAllCaps("HELLO WoRLD!!!")
False


Creative Commons License
IsAllCaps by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search
Thank you for your support!
This page has been accessed 2,443 times.  This page was last modified 02:09, 27 January 2013 by Brent Spaulding.   Disclaimers