更多"编写如下程序: Private Sub Command1_Click"的相关试题:
[单项选择]有人编写了如下程序:
Private Sub Form_Click( )
Dim s As Integer, x As Integer
s=0
x=0
Do While s=10000
x=x+1
s=s+x^2
Loop
Print s
End Sub
上述程序的功能是:计算s=1+22+32+…+n2+…,直到s>10000为止。程序运行后,发现得不到正确的结果,必须进行修改。下列修改中正确的是( )。
A. 把x=0改为x=1
B. 把Do While s=10000改为Do While s<=10000
C. 把Do While s=10000改为Do while s>10000
D. 交换x=x+1和s=s+x^2的位置
[填空题]编写如下代码:
Dim Flag As Boolean
Private Sub Form MouseDown (Button As Integer,
Shift As Integer, X As Single, Y As Single)
Flag = True
End Sub
Private Sub Form MouseMove (Button As Integer,
Shift As Integer, X As Single, Y As Single)
Flag = False
End Sub
Private Sub Form_ MouseUp (Button As Integer,
Shift As Integer, X As Single, Y As Single)
If Flag = False Then
Print "DDDD"
End If
End Sub
程序运行后,如果想在窗体上输出DDDD,则应执行的操作为______ 。
[单项选择]编写如下事件过程: Private Sub Form Click( ) Dim Char As String,i As Integer Const ch$="#" msg$= "Enter a String:" char=InputBox$(msg$) n=Len(Char) For i=1 To n If Mid$(char,i,1)=ch$ Then Exit For End If Next i Print i - 1 End Sub 其中InputBox函数的功能是弹出一个输入对话框,按所给参数给出提示,等待用户输入,并返回输入的内容。程序运行后,单击窗体,如果在输入对话框内输入字符串“12ab$%*/#fg”,则窗体上输出
A. 2
B. 2
C. 5
D. 8
[单项选择]在窗体中添加一个命令按钮,编写如下程序:
Private Sub Sub1(p,m,n)
p=p+1:m=m+1:n=n+1
Print "sub1:";p;m;n
End Sub
Private Sub Command1_Click( )
a1=1:b=2:c1=3
Call Sub1(a,b1+3,c1)
Print"Main:";a1;b1;c1
End Sub
程序运行后,输出结果为
[单项选择]在窗体上画一个命令按钮,然后编写如下程序 Private Sub Command4 Click( ) Dim a As Integer,b As Integer a=1 b=2 Print N(a,b) End Sub Function N(x As Integer,y As Integer)As Integer N=IIf(x>y,x,y) End Function 程序运行后,单击命令按钮,输出结果为
A. l
B. 2
C. 5
D. 8
[单项选择]在窗体上画一个命令按钮,然后编写如下程序
Private Sub Command1_Click( )
Dim a As Integer,b As hiteger
a=1
b=2
Print N(a,b)
End Sub
Function N(x As Integer,y As Integer)As Integer
N=IIf(x>y,x,y)
End Function
程序运行后,单击命令按钮,输出结果为
A. 1
B. 2
C. 5
D. 8
[填空题]在窗体上画一个命令按钮Command1,然后编写如下程序:
Private Sub Command1_Click( )
Dim arr( ) As Integer
ReDim arr(3)
For i=0 To 3
art(i)=i
Next i
x=InputBol("请输入一个数字:")
If Val(x)>4 Then
ReDim arr(4)
art(4)=x
End If
Me.Print (arr(4)-arr(3))
End Sub
程序运行后,单击命令按钮,在输入对话框中输入12,输出结果为 【10】 。
[填空题]在窗体上画一个命令按钮Command1,然后编写如下程序:
Private Sub Command1_Click( )
Dim arr( )As Integer
ReDim arr(3)
For i=0 To 3
arr(i)=i
Next i
x=InputBox("请输入一个数字:")
If Val(x)>4 Then
ReDim arr(4)
arr(4)=x
End If
Me.Print(arr(4)-arr(3))
End Sub
程序运行后,单击命令按钮,在输入对话框中输入12,输出结果为 【10】 。
[单项选择]在窗体上画一个命令按钮,然后编写如下程序:
Option Base 1
Private Sub Command1 Click( )
Dim Arr1(12)As Integer, Arr2(3)As Integer
Dim Sum As Integer
Sum = 2
For i=1 To 12
Arrl(i)= i
Next i
For i=1 To 3
Arr2(i)= Arrl(i*i)
Next i
For i = 1 To 3
Sum = Sum + Arr2(i)
Next i
Print Sum
End Sub
程序运行后,单击命令按钮,在窗体上的输出结果为
A. 16
B. 24
C. 32
D. 36