15.統計“英文句子單詞平均長度”的程序,其實現功能為:在文本框Text1中輸入要統計的英文句子,單擊“統計”按鈕Command1.進行統計,求出句子中共有幾個單詞、句子單詞的平均長度,并顯示在標簽框Label1中。程序運行界面如圖所示。 (1)代碼“Private Sub Command1_Click ( )”中的Command1_Click是
(單選,填字母:A.對象名/B.事件名/C.事件處理過程名)。 (2)實現上述功能的VB程序如下,請在橫線處填入合適的代碼。 Private Sub Command1_Click ( ) Dim s As String Dim n As Integer Dim cnt As Integer Dim i As Integer Dim num As Single Dim cd As Single Dim ave As Single s=Text1.Text n=Len(s) num=0 cd=0 cnt=0 For i=1To n ①
If c>=“a“And c<=“z“or c>=“A“And c<=“Z“Then cnt=cnt+1 ElseIf c>=“0“And c<=“9“Then‘單詞中可能有數字,也進行統計 cnt=cnt+1 Else If cnt>0Then num=num+1 cd=cd+cnt ②
End If End If Next i ave=cd/num Label1.Caption=“總共有“+Str(num)+“個單詞,平均長度為“+Str(ave) End Sub
個類(填數字)。 (2)實現上述功能的VB程序如下,請在橫線處填入合適代碼。 Private Sub Command1_Click( ) Dim s As String,s1As String,s2As String,num As Integer s=“VisualBASIC“ s1=Text1.Text s2=““ i=1 Do While①
num=Val(Mid(s1,i,1))+i num=num Mod 11 If num=0Then num=11 s2=②
i=i+1 Loop Text2.Text=s2 End Sub (3)若密文是“uAV”,則明文是