怎样得到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),其他的全是空(“”)的啦?
并把他保存到一变量中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),其他的全是空(“”)的啦?
解决方案 »
- 无聊,散分。
- mscomm奇怪的问题。
- 关于保存问题的对话框
- 关于水晶报表的段落值问题,急!
- 跪求用VB6.0开发抽奖的程序,请各路高手进入!
- 怎样将text1.text的内容添加到数据库中
- 在程序中怎么判断一段已经Base64加密后的字符到底是文本还是应用程序呢,是不是再解码时会自动判断
- 关于发邮件的问题
- VB编程历史上的一个转折点,超级压缩,可以把任何东东(包括你的显示器)压缩成20K左右,附源代码
- 快乐少年 请问 怎么写 chrw(60A8) 有错么
- 使用MSComm控件读取串口数据时,OnComm只有第一次能读回内容,之后便不再触发了
- 在 richtext 里 对齐文本 各列用空格分开 要各列左对齐 用到了 len lenb()怎么总对不齐?
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
其实早就应该把答案给贴出来了,但一直没有时间,这是本人最后使用的愚蠢办法!
希望还有能人给出更好的办法。