Microsoft KB Archive/50810

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

WordBasic Instr() Statement Defined

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

1.00 1.10 1.10a 2.00 WINDOWS

Summary: The Word BASIC Instr() statement searches for a string in the specified String variable. If the [n] argument is supplied, the search starts at character [n].

Syntax

Num = Instr([n], String, Search_String)

Example

Sub MAIN Open “FOO.DOC” For Input As #4 ’Open the document X = Lof(#4) ’Determine file length A$ = Input<math display="inline">(X, #4) 'Place document in 'variable A</math> B$ = “String to Search” ’Assign string to ’variable B$ Num = InStr(1, A<math display="inline">, B</math>) ’Starting at character ’1, search A$ for ’variable B$ if Num > 0 then Print “String found at Character:”+ Num else Print “No Match found” endif Close #4 End Sub For more information on WordBasic functions, please refer to the “Microsoft Word for Windows Technical Reference.”

Additional reference words: w4wmacro 1.0 1.1 1.1a 1.00 1.10 1.10a 2.00