vb编程问题 从文本框中输入一段英文 统计其单词数(单词之间用空格或"."隔开)
1个回答
展开全部
Private Sub Command1_Click()
If Text1 = "" Then Exit Sub
t = Text1.Text
n = 1
For i = 1 To Len(t)
t = Replace(t, ".", " ")
t = Replace(t, " ", " ")
Next i
For i = 1 To Len(t)
If Mid(t, i, 1) = " " Or Mid(t, i, 1) = "." Then n = n + 1
Next i
If Mid(t, 1, 1) = " " Or Mid(t, 1, 1) = "." Then n = n - 1
If Mid(t, Len(t), 1) = " " Or Mid(t, Len(t), 1) = "." Then n = n - 1
Print n
End Sub
If Text1 = "" Then Exit Sub
t = Text1.Text
n = 1
For i = 1 To Len(t)
t = Replace(t, ".", " ")
t = Replace(t, " ", " ")
Next i
For i = 1 To Len(t)
If Mid(t, i, 1) = " " Or Mid(t, i, 1) = "." Then n = n + 1
Next i
If Mid(t, 1, 1) = " " Or Mid(t, 1, 1) = "." Then n = n - 1
If Mid(t, Len(t), 1) = " " Or Mid(t, Len(t), 1) = "." Then n = n - 1
Print n
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询