TechWhirl (TECHWR-L) is a resource for technical writing and technical communications professionals of all experience levels and in all industries to share their experiences and acquire information.
For two decades, technical communicators have turned to TechWhirl to ask and answer questions about the always-changing world of technical communications, such as tools, skills, career paths, methodologies, and emerging industries. The TechWhirl Archives and magazine, created for, by and about technical writers, offer a wealth of knowledge to everyone with an interest in any aspect of technical communications.
This example asks the user to type a word,
which is assigned to the variable word$. You could
use this variable in a macro that
counts the occurrences of a given word in the active document
(as in the example for EditFindFound()).
The following example prompts the
user to type a number from 1 to 10. InputBox$() returns what
the user types as a string, which the
Val() function converts to a number to assign to the numeric
variable num. Note that if the user spells
out "Ten" instead of typing "10," Val() returns 0.
num = Val(InputBox$("Type a number from 1 to 10:"))
This example asks the user to type two lines,
which are assigned to the variable a$. The InStr()
function checks for a newline character;
if one exists, the Left$() and Right$() functions are used
to redefine a$ without the newline character.
a$ = InputBox$("Type two lines:")
newline = InStr(a$, Chr$(11))
If newline <> 0 Then
a$ = Left$(a$, newline - 1) + Right$(a$, Len(a$) - newline)
End If