下面程序运行时,若输入“Visual Basic Prograrmming”,则在窗体上输出的是( ) Private Sub Command1_Click() Dim count(25)As Integer,ch As String ch=Ucase(InputBox("请输入字母字符串")) For k=1 To Len(ch) n=Asc(Mid(ch,k,1))-Asc("A") If n>=0 Then count(n)一count(n)+1 End If Next k m=count(0) For k=1 To 25 If m<count(k) Then m=count(k) End If Next k Print m End Sub
A: 0
B: 1
C: 2
D: 3
A: 0
B: 1
C: 2
D: 3
举一反三
- 下面程序的输出结果是 Private Sub Command1_Click() ch$="ABCDEF" proc ch Print ch End Sub Private Sub proc(ch As String) S="" For k=Len(ch) To 1 Step-1 s=s & Mid(ch,k,1) Next k ch=s End Sub
- 下面程序的输出结果是( )Private Sub proc(ch As String) s = "" For k = Len(ch) To 1 Step -1 s = s & Mid(ch, k, 1) Next k ch = sEnd SubPrivate Sub Command1_Click() ch$ = "ABCDEF" proc ch Print ch End Sub A: ABCDEF B: A C: FEDCBA D: F
- 设有如下事件过程:Private Sub Command1_Click() ch = "ABCDEFG" n = Len(ch) k = 1 Do Print Mid(ch, k, 1); Mid(ch, n, 1); k = k + 1 n = n - 1 Loop Until k > nEnd Sub运行此过程所产生的输出是 A: AGBFCEDD B: AGBFCED C: GFEDCBA D: GAFBECD
- 3.输入一个正整数m(>2),判断m是否为素数,并输出结果。请将程序补充完整。 Private Sub Form_Click() Dim m%, i%, k% m = InputBox("请输入m的值(>2)") k = 1 For i = 【1】To【2】 If 【3】 Then k = 0 Next i If 【4】 Then Print m & "是素数" Else Print m & "不是素数" End If End Sub
- 中国大学MOOC: 有如下程序段: Dim i%, j%, n%, m%, k% m = 0 : k = 0 For i = 1 To 5 k = k + 1 n = 0 For j = 1 To 2 n = n + 1 m = m + 1 Next j Next i MsgBox(k & & n & & m)运行该程序代码段后,消息对话框中显示的内容为( )。