举一反三
- 窗体上有一个名称为 Command1 的命令按钮。其单击事件过程如下: Private Sub Command1_Click() Open "c:1.txt" For Input As #1 Open "c:2.txt" For Output As #2 Do While Not EOF(1) Line Input #1, str1 Print #2, str1 Loop Close End Sub 以下关于上述程序的叙述中,错误的是 ________ 。
- 窗体上有一个名称为Command1的命令按钮,一个名称为List1的列表框。命令按钮的单击事件过程如下: Private Sub Command1_Click() Open "c:f1.txt" For Input As #1 Do While Not EOF(1) Input #1, str1 List1.AddItem str1 Loop Close End Sub 对于上述程序,以下叙述中错误的是________。
- 窗体上有一个名称为 Command1 的命令按钮。要求编写程序,把文件 f1.txt 的内容写到文件 f2.txt 中,然后将 f1.txt 删除。命令按钮的单击事件过程如下: Private Sub Command1_Click() Open "c:f1.txt" For Input As #1 Open "c:f2.txt" For Output As #2 Do While Not EOF(2) Line Input #1, str1 Print #2, str1 Loop Close Kill "c:f1.txt" End Sub 该程序运行时发生错误,应该进行的修改是 ________ 。
- 窗体上有一个名为Command1的命令按钮,编写如下事件过程: Private Sub Command1_Click() i = 0 Do While i < 8 For j = 1 To i n = n + 1 Next i = i + 1 Loop Print n End Sub 运行程序,单击命令按钮,则输出结果是______。
- 在窗体上有一命令按钮Command1,其Click事件代码如下: Private Sub Command1_Click() Dim a%, b%, i%, n% For i = 1 To 10 n = InputBox("请输入一个整数", "输入数据框", 2) If n Mod 2 = 0 Then a = a + 1 Else b = b + 1 End If Next i MsgBox ("运行结果a=" & str(a) & ", b=" & str(b)) End Sub
内容
- 0
在窗体上画一个通用对话框图,其Name属性为Cont,瑞画一个命令按钮,Name属性为Command1,然后编写如下事件过程: Privute Sub Command1_Click( ) Cont.FileName=" " Cont.Flags=vbOFNFileMustExist Cont.Filter="All Files| * . *" Cont.FilterIndes_3 Cont.DialogTitle="Open File" Cont.Action=1 If Cont.FileName=" " Then MsgBox "No file selected" Else Open Cont.FileName For Input As #1 Do While Not EOF(1) Input #1. b$ Print b$ Loop End If End Sub 以下各选项,对上述事件过程描述错误的是( )。 A: ++i; B: D--; C: c++; D: --f;
- 1
以下事件过程的功能是:从已存在于磁盘上的顺序文件Num1.txt中读取数据,计算读出数据的平方值,将该数据及其平方值存入新的顺序文件Num2.txt中。则在以下横线处合适的语句是( )。 Private Sub Form_Click() Dim x As Single,y As Single Open "Num1.txt" For Input As #1 Open "Num2.txt" For Output As #2 Do While Not EOF(1) ______ Print x y=x^2 Print y Loop Close #1,#2 End Sub A: Input #1,y Print#2,x,y B: Input #2,x Print #1,x,y C: Print #1,x Input#2,x,y D: Input #1,x Print #2,x,y
- 2
声明一个变量为局部变量应该用( )。 A: Private Sub Command1 Click() n=5:x=1 Do X=X * I I=I + 1 Loop While I < n Print x End Sub B: Private Sub Command1_Click() n=5:X=1:I=1 Do X=X*I I=I + 1 Loop While I <n Print x End Sub C: Private Sub Command1_Click() n=5:X=1:I=1 Do X=X * I I=I + 1 Loop While I<=n Print X End Sub D: Private Sub Command1_Click() n=5:X=1:I=1 Do X=X * I I=I + 1 Loop While I>n Print X End Sub
- 3
在窗体上画一个名称为Command1的命令按钮,然后编写如下事件过程: Private Sub Command1_Click() a=0 For i=1 To 2 For j=1 To 4 If j Mod 2<>0 Then a=a-1 End If a=a+1 Next j Next i Print a End Sub 程序运行后,单击命令按钮,输出结果是 A: 0 B: 2 C: 3 D: 4
- 4
在窗体上画一个名称为Command 1命令按钮,然后编写如下事件过程: Private Sub Command1_Click() c="ABCD" For n=1 To 4 Print ▁▁▁▁ Next End Sub 程序运行后,单击命令按钮,要求在窗体上显示如下内容: D CD BCD ABCD 则在横线处填入的内容为?