WD: Lowercase a, b, and c Do Not Compare Correctly in WordBasic

Last reviewed: February 2, 1998
Article ID: Q94855

The information in this article applies to:
  • Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a

SYMPTOMS

The logical string operation example on page 35 of "Using WordBasic", which compares the values of "c" and "D", does not yield the correct result.

MORE INFORMATION

According to "Using WordBasic," the evaluation of (n = "c" > "D") produces a "TRUE" (non-zero) result because "c" occurs after "D" in the ANSI code set. When you perform this operation in a WordBasic macro, the macro incorrectly reports a "FALSE" (zero) result.

The incorrect result also occurs if you replace "c" with the lowercase letters "a" or "b". In contrast, the lowercase letters "d" through "z" yield correct results. In addition, if you compare the lowercase letters "a", "b" and "c" to their uppercase counterparts (A, B, and C), the macro yields a correct result of "TRUE" (non-zero).

WORKAROUND

Use the ASC macro command to return the ANSI code for the text strings to be compared. The following macro produces correct comparison results:

   n = ASC("c") > ASC("D")
   print n

When you run the macro, the correct value (TRUE) appears on the status bar.

Steps to Reproduce Problem

The following macro incorrectly reports a "FALSE" (zero) result instead of the correct result of "-1" (TRUE):

      Sub Main
      n = "c" > "D"
      print n
      End Sub

In addition, if you change the logical operator from ">" to "<", as shown in the example below, the macro also yields incorrect results ("-1" or "TRUE").

   n = "c" < "D"

STATUS

Microsoft has confirmed this to be a problem in the versions of Microsoft Word listed above. This problem was corrected in Word 97 for Windows and Word 98 Macintosh Edition.

REFERENCES

"Using WordBasic," by WexTech Systems and Microsoft, page 35


Additional query words: winword2
Keywords : kbmacroexample macword winword word6 word7 word95 kbcode kbmacro
Version : WINDOWS:2.0,2.0a,2.0a- CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a;MACINTOSH:6.0,6.0.1,6.0.1a
Platform : MACINTOSH WINDOWS
Issue type : kbbug kbhowto
Solution Type : kbfix kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.