Microsoft KB Archive/107533: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - ">" to ">")
 
(2 intermediate revisions by the same user not shown)
Line 27: Line 27:
For example:
For example:


<pre class="FIXEDTEXT">    first line  &lt;soft return&gt;
<pre class="FIXEDTEXT">    first line  <soft return>
   &lt;hard return&gt;
   <hard return>
   second line  &lt;soft return&gt;
   second line  <soft return>
   &lt;hard return&gt; </pre>
   <hard return> </pre>
<br />
<br />


Line 39: Line 39:


<pre class="CODESAMP">  Sub MAIN
<pre class="CODESAMP">  Sub MAIN
   a$ = InputBox$(&quot;Type more than one line&quot;)
   a$ = InputBox$("Type more than one line")
   a$ = CleanString$(a$)
   a$ = CleanString$(a$)
   Insert a$
   Insert a$
Line 47: Line 47:
For example:
For example:


<pre class="FIXEDTEXT">  first line  &lt;hard return&gt;
<pre class="FIXEDTEXT">  first line  <hard return>
   second line  &lt;hard return&gt; </pre>
   second line  <hard return> </pre>
To insert a soft return after each new line entered into an InputBox, use the following macro example:
To insert a soft return after each new line entered into an InputBox, use the following macro example:


<pre class="CODESAMP">  Sub MAIN
<pre class="CODESAMP">  Sub MAIN
   a$ = InputBox$(&quot;Enter more than one line&quot;)
   a$ = InputBox$("Enter more than one line")
   Para = InStr(a$, Chr$(10))
   Para = InStr(a$, Chr$(10))
   While Para &lt;&gt; 0
   While Para <> 0
     a$ = Left$(a$, para - 1) + Right$(a$, Len(a$) - para)
     a$ = Left$(a$, para - 1) + Right$(a$, Len(a$) - para)
     Para = InStr(a$, Chr$(10))
     Para = InStr(a$, Chr$(10))
Line 60: Line 60:
   Insert a$
   Insert a$
   End Sub </pre>
   End Sub </pre>
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code &quot;as is&quot; without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.<br />
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.<br />
<br />
<br />
Kbcategory: kbusage kbmacro
Kbcategory: kbusage kbmacro

Latest revision as of 16:51, 20 July 2020

InputBox$() Function Inserts an Extra Soft Return

Q107533



The information in this article applies to:


  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows, versions 7.0, 7.0a





SUMMARY

If the ENTER key is pressed in an edit box created by the WordBasic InputBox$ function, an erroneous soft return (newline character) will be inserted into the document in addition to a hard return (paragraph mark).

For example:

     first line  <soft return>
   <hard return>
   second line  <soft return>
   <hard return> 



MORE INFORMATION

To remove the soft return characters, use the CleanString$() function, as in the following macro example:

   Sub MAIN
   a$ = InputBox$("Type more than one line")
   a$ = CleanString$(a$)
   Insert a$
   End Sub 

The above macro inserts a hard return after each new line entered into the InputBox$() edit control.

For example:

   first line   <hard return>
   second line  <hard return> 

To insert a soft return after each new line entered into an InputBox, use the following macro example:

   Sub MAIN
   a$ = InputBox$("Enter more than one line")
   Para = InStr(a$, Chr$(10))
   While Para <> 0
    a$ = Left$(a$, para - 1) + Right$(a$, Len(a$) - para)
    Para = InStr(a$, Chr$(10))
   Wend
   Insert a$
   End Sub 

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Kbcategory: kbusage kbmacro

Additional query words: 6.0 InputBox$() input box paragraph word6 7.0 word95 word7 winword cleanstring hard carriage newline inputbox duplicate

Keywords :
Issue type :
Technology :


Last Reviewed: November 4, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.