3个回答
展开全部
Private Sub Command1_Click()
Dim b As Integer, a As String, I As Integer, c As String, d As String
a = Text1.Text
c = "": d = ""
For I = 1 To Len(a)
b = Asc(Mid(a, I, 1))
If (b >= 65 And b <= 90) Or (b >= 97 And b <= 122) Then
d = d & Mid(a, I, 1)
Else
If d <> "" Then c = c & d & vbCrLf
d = ""
End If
Next I
Print c
End Sub
Dim b As Integer, a As String, I As Integer, c As String, d As String
a = Text1.Text
c = "": d = ""
For I = 1 To Len(a)
b = Asc(Mid(a, I, 1))
If (b >= 65 And b <= 90) Or (b >= 97 And b <= 122) Then
d = d & Mid(a, I, 1)
Else
If d <> "" Then c = c & d & vbCrLf
d = ""
End If
Next I
Print c
End Sub
追问
我要处理的是一个也句子中的每个词。但当那个词尾没有标点的时候它就不被输出了。
追答
Private Sub Command1_Click()
Dim b As Integer, a As String, I As Integer, c As String, d As String
a = Text1.Text
c = "": d = ""
For I = 1 To Len(a)
b = Asc(Mid(a, I, 1))
If (b >= 65 And b = 97 And b "" Then c = c & d & vbCrLf
d = ""
End If
Next I
if d"" Then c = c & d & vbCrLf‘这里再加一句试下
Print c
End Sub
展开全部
Private Sub Command1_Click()
Dim a() As String
a = Split(Text1.Text)
For i = 0 To UBound(a)
Print a(i)
Next
End Sub
Dim a() As String
a = Split(Text1.Text)
For i = 0 To UBound(a)
Print a(i)
Next
End Sub
追问
嗯,但我想把提取出来字符串的最后一个标点去掉。代码如下:
dim b as integer
b=asc(right(a()),10)
for i=1 to ubound(a)
if b90 then a(i)=(left(a(i),len(a(i))-1))
?a(i)
next i
达不到目的啊,把最后一个符号去掉。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
如果每个单词用一个空格" " 隔开你可以这样
dim a() as string '定义存放单词的数组
a=split(trim(text1.text)," ")
dim a() as string '定义存放单词的数组
a=split(trim(text1.text)," ")
更多追问追答
追问
嗯,这样是不错。例如此句“today, i am so happy.”,我们获得的就是“today,”,还需要一个判断,把单词后面的符号去掉。应该取该字符最后一位,利用ascii值来判断是否为字符吧?
追答
可以 小写a到z asc好像是97 到122 大写的是 65到90
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询