标点符号就那么多,我想不会超过20个吧,把所有你认为可用于断句的符号都检测一下就行了。方法很多,用Instr就不错。写个函数给你:Function FindBreak(start as long ,word As string) as Long dim i as long,s As string s=",;”。!~……)?" '自己随便加上你想检测的断句符 for i=1 to len(s) FindBreak=instr(start,word,mid(s,i,1)) if FindBreak>0 then exit function next end Function
1 将 TextBox 放在一个 Enabled = false,BorderStyle = 0 的 Frame 中。2 strWords = "我是你的朋友。他也是你的朋友!"Private Sub Text1_Click() Dim p As Integer, n As Integer p = InStr(Len(Text1) + 1, strWords, "。") n = InStr(Len(Text1) + 1, strWords, "!") If p > n Then p = n n = InStr(Len(Text1) + 1, strWords, "?") If p > n Then p = n n = InStr(Len(Text1) + 1, strWords, "……") If p > n Then p = n + 1 '...... Text1 = left(strWords, p) End Sub
1.Locked=true2. dim a(10) as string dim i as integer sub form_load() i=0 a(0)="我是你的朋友。" a(1)="他也是你的朋友!" ... end subsub command1_click() text1.text=text1.text & a(i) i=i+1 end sub
1、不修改内容又要显示颜色,请将Text换成Label; 2、具体实现如下: 一个Text1用于存放原始字符串,一个Label1用于显示,一个Command,代码如下: Private Sub Command1_Click() Static i As Integer Do While i <= Len(Text1) i = i + 1 If Mid(Text1, i, 1) = "," Or Mid(Text1, i, 1) = "。" Or _ Mid(Text1, i, 1) = "?" Or _ Mid(Text1, i, 1) = "!" Or _ Mid(Text1, i, 1) = ";" Then '此处假定以,。?!;进行分界 Label1.Caption = Left(Text1, i) Exit Do End If Loop End Sub
2:如果确定是以句号断句
可以这样
Dim arr() as string
arr=Split(a,"。")然后按一下回车,显示一个数组元素或者是组合即可.
2.不一定用句号断句啊,只要是和句号在句子中作用一样的标点如,“!”、“?”等,都要断句的,这样的话还有其他办法吗?谢谢!
dim i as long,s As string
s=",;”。!~……)?" '自己随便加上你想检测的断句符
for i=1 to len(s)
FindBreak=instr(start,word,mid(s,i,1))
if FindBreak>0 then exit function
next
end Function
将 TextBox 放在一个 Enabled = false,BorderStyle = 0 的 Frame 中。2
strWords = "我是你的朋友。他也是你的朋友!"Private Sub Text1_Click()
Dim p As Integer, n As Integer
p = InStr(Len(Text1) + 1, strWords, "。")
n = InStr(Len(Text1) + 1, strWords, "!")
If p > n Then p = n
n = InStr(Len(Text1) + 1, strWords, "?")
If p > n Then p = n
n = InStr(Len(Text1) + 1, strWords, "……")
If p > n Then p = n + 1
'......
Text1 = left(strWords, p)
End Sub
2.不一定用句号断句啊,只要是和句号在句子中作用一样的标点如,“!”、“?”等,都要断句的,这样的话还有其他办法吗?谢谢!
不让修改,直接设置Text的Locked=true标点的只能挨个判断了.
dim a(10) as string
dim i as integer
sub form_load()
i=0
a(0)="我是你的朋友。"
a(1)="他也是你的朋友!"
...
end subsub command1_click()
text1.text=text1.text & a(i)
i=i+1
end sub
2、具体实现如下:
一个Text1用于存放原始字符串,一个Label1用于显示,一个Command,代码如下:
Private Sub Command1_Click()
Static i As Integer
Do While i <= Len(Text1)
i = i + 1
If Mid(Text1, i, 1) = "," Or Mid(Text1, i, 1) = "。" Or _
Mid(Text1, i, 1) = "?" Or _
Mid(Text1, i, 1) = "!" Or _
Mid(Text1, i, 1) = ";" Then '此处假定以,。?!;进行分界
Label1.Caption = Left(Text1, i)
Exit Do
End If
Loop
End Sub