17324.html

来自「VB技巧问答10000例 VB技巧问答10000例」· HTML 代码 · 共 24 行

HTML
24
字号
<html>  <head>    <title>Re: 请问RichTextBox..</title>  </head>  <body bgcolor="#FFFFFF" vlink="#808080">    <center>      <h1>Re: 请问RichTextBox..</h1>    </center><hr size=7 width=75%><hr size=7 width=75%><p>Posted by <a href="mailto:stupids@ms5.url.com">小瓜瓜</a> on August 16, 1999 at 02:00:36:<p>In Reply to: <a href="16865.html">Re: 请问RichTextBox..</a> posted by 小琳 on August 07, 1999 at 17:20:35:<p>: : 请问在richtextbox中如何在第n行中<br>: : 的第几个字元开始插入文字呢?<p>: :::程式如下:<br>: Option Explicit<p>: Private Sub Command1_Click()<br>:     Dim i As Integer, a As Integer, b As Integer<br>:     <br>:     i = 0<br>:     a = 0<br>:     b = 0<br>:     i = InStr(1, RichTextBox1.Text, Chr(10))<br>:     a = 1<br>:     Do While a < Val(Text1)<br>:         b = i<br>:         i = InStr(i + 1, RichTextBox1.Text, Chr(10))<br>:         a = a + 1<br>:     Loop<br>:<br>     RichTextBox1.Text = Left(RichTextBox1.Text, b) & Mid(RichTextBox1.Text, b + 1, Val(Text2)) & Trim(Text3.Text) & Mid(RichTextBox1.Text, b + Val(Text2) + 1)<br>:     MsgBox RichTextBox1.Text<br>:     <br>: End Sub<p><p>Dim R As Long '第几行<br>Dim P As Long '第几个字<br>Dim L As Long '嘿嘿<br>Dim MyStr As String '嘿嘿<br>Dim InsStr As String '要插入的字串<p>MyStr = RichTextBox1.Text<p>R = 4 '第四行<br>P = 10 '第十个字<br>InsStr = "Hello!" '插入"Hello!"<p>For N = 2 To R<br>    P = InStr(MyStr, Chr(10))<br>    L = L + P + 2<br>    MyStr = Right(MyStr, Len(MyStr) - P)<br>    MsgBox MyStr & ":" & L<br>    If P = 0 Then Exit For<br>Next<p>L = L + R<br>RichTextBox1.SelStart = L<br>RichTextBox1.SelText = InsStr<br><br><ul><li><a href="http://www.hello.com.tw/~stupids">小瓜瓜VB调理包</a></ul><br><hr size=7 width=75%><p><a name="followups">Follow Ups:</a><br><ul><!--insert: 17324--></ul><!--end: 17324--><br><hr size=7 width=75%><p></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?