Microsoft KB Archive/51481

From BetaArchive Wiki

Cannot Pass by Reference in Word Embedded Basic

PSS ID Number: Q51481 Article last modified on 09-12-1991

1.00 1.10 1.10a WINDOWS

Summary: When writing a subroutine that has parameters being passed, it is not possible to pass a variable by reference (the value of the address) in Microsoft Word for Windows embedded Basic. In other words, you can pass only by value (the contents of the address). The following is a simple macro that illustrates this limitation: Sub MAIN Let Number = 3 ’ let the integer “Number” equal 3 Foo (Number) ’ call “Foo” passing the value of “Number” Print Number ’ print the value of “Number” End Sub Sub Foo (int1) ’ subroutine “Foo” with local variable “int1” int1 = int1 + 1 ’ “int1” is changed to the value of “Number” End Sub ’ plus one. When executed, the value of “Number” when printed after the call to “Foo” will still equal 3. This is because int1 is given only the value of the variable “Number”, not the reference.

More Information: In Word for Windows embedded Basic, only Basic input and output functions are included. Therefore, embedded Basic is a “subset” of QuickBASIC, and it is limited to passing only values (that is, integers or strings).

Additional reference words: w4wmacro wordbasic