怎样得到richtextbox中每一行字符串?(一行一行的)
并把他保存到一变量中Set wordobj = New Word.Application '创建一WORD实例    On Error Resume Next
    ' Str_Diff = " ,;:?!." + Chr(13) + Chr(10)
    Str_Diff = Chr(13) + Chr(10)
    Len_S = Len(RichTextBox1.Text)
    Start = 1
    While Start < Len_S
        struc = ""
        i = 0
        j = 0
        '判断一行的首位置
         While (Start + i) <= Len_S And Mid(RichTextBox1.Text, Start + i, 1) = " "
         i = i + 1
         Wend
        '判断一行的长度
         While (Start + i + j) <= Len_S And InStr(1, Str_Diff, Mid(RichTextBox1.Text, Start + i + j, 1), vbBinaryCompare) <= 0
         j = j + 1
         Wend
        '截取一行出来
        struc = Mid(RichTextBox1.Text, Start + i, j)处理文章如下(部分):
part Two
READINGIC ENTERED ACTIVITIES
qn-Class q延ading
Pre-Reading
Directions:Work in groups to discuss whether you would give your time,yourfavorite(最
喜欢的)books,your money,or your blood to
1)afriend;
2)a stranger.
Passage Reading
但还是不对?
只能取出第一行(part Two),其他的全是空(“”)的啦?

解决方案 »

  1.   

    richtextbox没有lines这个属性或方法
      

  2.   

    Dim i As Long, j As Long
      Dim str_diff As String
      Dim struc As String
      Dim len_s As Long, start As Long
      Dim k As Integer
        On Error Resume Next
        str_diff = Chr(13) + Chr(10)
        len_s = Len(RichTextBox1.Text)
        start = 1
        While start < len_s
            struc = ""
            i = 0
            j = 0
             While (start + j) <= len_s And InStr(1, str_diff, Mid(RichTextBox1.Text, start + j, 1), vbBinaryCompare) <= 0
             j = j + 1
             Wend
            '截取一行出来
            struc = Mid(RichTextBox1.Text, start, j)
            k = k + 1
            If k = 3 Then   '找出第三行的句子
              If struc = "" Then
                MsgBox "当前为空白行"
                Exit Sub
              Else
                MsgBox struc
                Exit Sub
              End If
            End If
            RichTextBox1.SelStart = start - 1
            RichTextBox1.SelLength = j
            RichTextBox1.SelText = struc
            RichTextBox1.SelProtected = False
            RichTextBox1.SetFocus
            start = start + j + 2
        Wend
      
    其实早就应该把答案给贴出来了,但一直没有时间,这是本人最后使用的愚蠢办法!
    希望还有能人给出更好的办法。
      

  3.   

    http://www.cnpopsoft.com/article.asp?id=18
      

  4.   

    如何得到RichTextBox中中第N行的文本