Microsoft KB Archive/51481

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 19:25, 12 August 2020 by X010 (talk | contribs) (X010 moved page Microsoft KB Archive/Q51481 to Microsoft KB Archive/51481 without leaving a redirect: Text replacement - "Microsoft KB Archive/Q" to "Microsoft KB Archive/")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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