【正确答案】【操作步骤】
步骤1:打开本题工程文件。
步骤2:打开代码编辑窗口,填入相应的代码以实现题目的功能。
参考答案(划线部分是需要填入的内容)
Option Base 1
Dim
s As String
Private Sub Commandl_Click()
Open App.Path&"\in5.dat"For Input As#1
Line Input#1.s
Close#l
Textl.Text=s
End Sub
Private Sub Command2_Click()
If kn(s)=0 Then
MsgBox"请先使用“读数据”功能!".
Else
ch$ =""
For k=l To Len(s)
c=Mid(s,k,1)
If C<>""Then
ch=ch+
c Else
IfLen(ch)=5 Then
m=m+l
End If
If found(ch,"a")Then
n=n+1
End If
ch=""
End If
Next k
Text2.Text=m
Text3.Text=n
End If
End Sub
Private Function found(st As String,ch As String)
As
Boolean′*****************************考生编写***********************************
For k=1 To Len(st)
a=Mid(st,k,l)
If a=ch Then
Found=True
Exit Function
End If
Nxet k
Found=False
′*******************************考生编写结束*********************************
End Function
Private Sub Form_Unload(Cancel As Integer)
Open App.Path&"\out5.dat"For Output As#1
Prnt#1.Text2.Text,Text3.Text
Close#l
End Sub
步骤3:调试并运行程序,单击“读数据”按钮,再单击“统计”按钮,结果如图5.5所示,最后关闭程序后按题目要求存盘。
