Microsoft KB Archive/64574

String Handling and Variable Assignment Problem in WordBasic

PSS ID Number: Q64574 Article last modified on 02-17-1993

1.00 1.10 1.10a WINDOWS

Summary: There is a problem in WordBasic involving the string-handling MID$, LEFT$, and RIGHT$ functions when inverting the expressions from one side of the equation to the other. Word for Windows returns the error message "Type Mismatch" (error #122). More Information: For example, the following should return the string "1": sub main AnyString$ =“1234567890” AOneCharChunk$ = LEFT$(AnyString$ ,1) Print AOneCharChunk$ end sub The macro above works correctly. You can also substitute RIGHT$ for LEFT$ in the expression, or replace the right-hand side of the expression with MID$(AnyString$, 1, 1). However, inverting the expression should also be true: sub main AnyString$="1234567890" AOneCharChunk$ =“A” MID$(AnyString$ ,1,1)=AOneCharChunk$ end sub Run this macro (you can also substitute the LEFT$ or RIGHT$ function) and you get a “Type Mismatch” error (#122). The use of the MID$, LEFT$, and RIGHT$ functions on the left side of an equation is permissible under Microsoft Quick Basic 4.x and WordBasic. Microsoft has confirmed this to be a problem in Word for Windows versions 1.0, 1.1, and 1.1a. We are researching this problem and will post new information here as it becomes available.

Additional reference words: w4wfont w4wmacro