Microsoft KB Archive/94855

{|
 * width="100%"|

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

 * }

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, 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 &quot;Using WordBasic&quot;, which compares the values of &quot;c&quot; and &quot;D&quot;, does not yield the correct result.

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

The incorrect result also occurs if you replace &quot;c&quot; with the lowercase letters &quot;a&quot; or &quot;b&quot;. In contrast, the lowercase letters &quot;d&quot; through &quot;z&quot; yield correct results. In addition, if you compare the lowercase letters &quot;a&quot;, &quot;b&quot; and &quot;c&quot; to their uppercase counterparts (A, B, and C), the macro yields a correct result of &quot;TRUE&quot; (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(&quot;c&quot;) > ASC(&quot;D&quot;) 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 &quot;FALSE&quot; (zero) result instead of the correct result of &quot;-1&quot; (TRUE):

     Sub Main n = &quot;c&quot; > &quot;D&quot; print n     End Sub In addition, if you change the logical operator from &quot;>&quot; to &quot;<&quot;, as shown in the example below, the macro also yields incorrect results (&quot;-1&quot; or &quot;TRUE&quot;).

  n = &quot;c&quot; < &quot;D&quot;

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.