编写一个vb程序,可以读入一个英文的文本文件,显示这个文件,并统计这个文件有多少个字符,多少个单词,
编写一个VB程序,可以读入一个英文的文本文件,显示这个文件,并统计这个文件有多少个字符,多少个单词,多少个空白(空格、TAB),多少个段落,按照单词的长度进行统计。求解求...
编写一个VB程序,可以读入一个英文的文本文件,显示这个文件,并统计这个文件有多少个字符,多少个单词,多少个空白(空格、TAB),多少个段落,按照单词的长度进行统计。
求解求解 展开
求解求解 展开
2个回答
展开全部
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim dzimu As Integer, xzimu As Integer, shuzi As Integer, a As Integer
dzimu = 0 : xzimu = 0 : shuzi = 0
For i = 1 To Len(TextBox1.Text)
a = Asc(Mid(TextBox1.Text, i, 1))
Select Case a
Case 97 To 122
xzimu = xzimu + 1
Case 65 To 90
dzimu = dzimu + 1
Case 48 To 57
shuzi = shuzi + 1
End Select
Next
MsgBox("有" & dzimu & "个大字幕" & "," & xzimu & "个小字幕" & "," & shuzi & "个数字")
End Sub
展开全部
Private Sub Command1_Click()
Open "d:\0.txt" For Input As #1
While Not EOF(1)
Line Input #1, s
wdstart = False
ch = ch + Len(s)
para = para + 1
i = 1
While i <= Len(s)
c = Mid(s, i, 1)
st = (c = " " Or c = Chr(9))
If st Then
sp = sp + 1
wdstart = False
Else
If c >= "A" And c <= "Z" Or c >= "a" And c <= "z" Then
If Not wdstart Then
word = word + 1
wdstart = True
End If
Else
wdstart = False
End If
End If
i = i + 1
Wend
Wend
Print "有"; ch; "个字符"
Print "有"; word; "个单词"
Print "有"; para; "个段落"
Print "有"; sp; "个空白"
Close #1
End Sub
Open "d:\0.txt" For Input As #1
While Not EOF(1)
Line Input #1, s
wdstart = False
ch = ch + Len(s)
para = para + 1
i = 1
While i <= Len(s)
c = Mid(s, i, 1)
st = (c = " " Or c = Chr(9))
If st Then
sp = sp + 1
wdstart = False
Else
If c >= "A" And c <= "Z" Or c >= "a" And c <= "z" Then
If Not wdstart Then
word = word + 1
wdstart = True
End If
Else
wdstart = False
End If
End If
i = i + 1
Wend
Wend
Print "有"; ch; "个字符"
Print "有"; word; "个单词"
Print "有"; para; "个段落"
Print "有"; sp; "个空白"
Close #1
End Sub
更多追问追答
追问
请问一下程序界面怎么设计
我调试的时候系统提示我缺少子程序函数或属性
追答
只要一个命令按钮
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询