用vb編寫程序代碼,題目是輸入20個英文單詞,統計期中以D字母(大小寫均可)的單詞有多少個?
題目:
用vb編寫程序代碼,題目是輸入20個英文單詞,統計期中以D字母(大小寫均可)的單詞有多少個?
解答:
以字母d開頭?
Private Sub Command1_Click()
Dim Arr(19) As String
Dim sum As Integer
sum = 0
For i = 0 To 19
Do While Arr(i) = ""
Arr(i) = InputBox("請輸入一個單詞")
Loop
If Mid(Arr(i),1,1) = "D" Or Mid(Arr(i),1,1) = "d" Then
sum = sum + 1
End If
Next
Print "以字母d開頭的單詞有" & sum & "個."
End Su
添加新評論