Differences between lower case and upper case

M

Maracay

Hi guys,

I am analyzing a code character by Character, in some point I need to work
just with the upper case letters, but when I ask, lets say If w-letter = “Iâ€
then, I also get lower case “iâ€, how can I solve this situation.

Thanks
 
J

John W. Vinson

Hi guys,

I am analyzing a code character by Character, in some point I need to work
just with the upper case letters, but when I ask, lets say If w-letter = “I”
then, I also get lower case “i”, how can I solve this situation.

Thanks

Take a look at the VBA help for the StrComp() function. Another approach is to
use the Asc() function to get the ASCII numeric value for the character:
?asc("i")
105
?asc("I")
73

If you're doing the comparisons in VBA code, you may want to try specifying

Option Compare Binary

instead of the default Option Compare Database at the very top of your module.
See the VBA help for "Option Compare".
 
M

M.L. Sco Scofield

Maracay,

Here are two of many options you can look into:

1 - The StrComp function using the vbBinaryCompare option will give you a
case sensitive comparison.

2 - You could use the Asc function to convert the character to its ASCII
value. The upper case characters have values of 65 (A) to 90 (Z) and the
lower case characters have values of 97 (a) to 122 (z).

Good luck.

Sco

M.L. "Sco" Scofield, MCSD, MCP, MSS, A+, Access MVP 2001 - 2005
Denver Area Access Users Group Past President 2006/2007 www.DAAUG.org
MS Colorado Events Administrator www.MSColoradoEvents.com
This email made with 100% recycled electrons!
Miscellaneous Access "stuff" at www.ScoBiz.com
 
C

Clifford Bass

Hi,

If you want to make John and Sco's solutions more generic and to
include Unicode characters, you can the AscW() function instead of the Asc()
function. Or you can use the UCase() function with the StrComp() function:

StrComp(strSomeChar, UCase(strSomeChar), vbBinaryCompare)

A return value of 0 indicates the letter in strSomeChar is an uppercase
letter.

Clifford Bass
 
C

Clifford Bass

Hi,

Little bit more: You will also get 0 if the item is not a letter. To
check to see if something is a letter that can have upper and lower case and
if the letter is in the upper case you might do something like this:

If StrComp(LCase(strSomeChar), UCase(strSomeChar), vbBinaryCompare) <> 0 And
StrComp(strSomeChar, UCase(strSomeChar), vbBinaryCompare) = 0 Then
.....
End If

Clifford Bass
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top