Re: binary vs. textual comparison
- From: "Albert D. Kallal" <PleaseNOOOsPAMmkallal@xxxxxxx>
- Date: Wed, 17 Jan 2007 15:16:42 -0700
you can fire up the immediate (debug) window in the code editor, and see the
following:
? "hello" = "HELLO"
True
(? = print)
So, if you type in the above comparison, you can see that ms-access
considers
upper and lower case the SAME. This is the case for most code.
There are cases when you want to be able to distinguish this, and thus have
to use an actual "internal" computer representing of the text.
so, you can use strcomp. From the help file:
Constant Value Description
vbUseCompareOption -1 Performs a comparison using
the setting of the
Option Compare
statement.
vbBinaryCompare 0 Performs a binary comparison.
vbTextCompare 1 Performs a textual comparison.
vbDatabaseCompare 2 Microsoft Access only. Performs a
comparison based on
information in your
database
If the two values are equal..then zero (0) is returned...
so, lets try it:
? strComp("hello","HELLO",vbTextCompare) = 0
True
? strComp("hello","HELLO",vbBinaryCompare) = 0
False
The "text" compare is just like how code normally compares two values.
However, if we do a "binary" compare, then the INTERNAL computer
representation of the two text strings is used, and as you can see.....it
becomes upper and lower case sensitive when you do this.
so, in the case that you need to test case (pun indented), you have to
resort to using strcomp and vbBinaryCompare.
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@xxxxxxx
.
- Prev by Date: Process Lingers After Code Execution
- Next by Date: Canceling OnKeyUp Event within a module
- Previous by thread: Process Lingers After Code Execution
- Next by thread: Canceling OnKeyUp Event within a module
- Index(es):
Loading