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

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
  • Microsoft 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 : kbmacro kbdtacode kbmacroexample winword macword word6 word7 word95
Version : MACINTOSH:6.0,6.0.1,6.0.1a; WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a
Platform : MACINTOSH WINDOWS
Issue type : kbbug kbhowto


Last Reviewed: December 23, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.