(24)窗体上有一个Text1文本框,一个Command1命令按钮,并有以下程序
Private Sub Commandl_Click()
Dim n
If Text1.Text<>"23456" Then
n=n+1
Print "口令输入错误" & n & "次"
End If
End Sub
希望程序运行时得到左图所示的效果,即:输入口令,单击“确认口令”命令按钮,若输入的口令不是“123456”,则在窗体上显示输入错误口令的次数。但上面的程序实际显示的是右图所示的效果,程序需要修改。下面修改方案中正确的是
A)在Dim n语句的下面添加一句:n=O
B)把Print "口令输入错误" & n & "次"改为Print "口令输入错误" +n+"次"
C)把Print "口令输入错误" & n & "次"改为Print "口令输入错误"&Str(n)&"次"
D)把Dim n改为Static n
(25)要求当鼠标在图片框P1中移动时,立即在图片框中显示鼠标的位置坐标。下面能正确实现上述功能的事件过程是
A)Private Sub P1_MouseMove(Button AS Integer,Shift As Integer,X As Single, Y As Single)
Print X,Y
End Sub
B)Private Sub P1_MouseDown(Button AS Integer,Shift As Integer,X As Single, Y As Single)
Picture.Print X,Y
End Sub
C) Private Sub P1_MouseMove(Button AS Integer,Shift As Integer,X As Single, Y As Single)
P1.Print X,Y
End Sub
D)Private Sub Form_MouseMove(Button AS Integer,Shift As Integer,X As Single, Y As Single)
P1.Print X,Y
End Sub
(26)计算二的近似值的一个公式是。
某人编写下面的程序用此公式计算并输出π的近似值:
Private Sub Comand1_Click()
PI=1
Sign=1
n=20000
For k=3 To n
Sign=-Sign/k
PI=PI+Sign/k
Next k
Print PI*4
End Sub
运行后发现结果为3.22751,显然,程序需要修改。下面修改方案中正确的是
A)把For k=3 To n 改为 For k=1 To n
B)把n=20000改为n=20000000
C)把For k=3 To n改为For k=3 To n Step 2
D)把PI=1改为PI=0