、
Private Sub Command1_Click()
Open “out.txt” For Inpit As#1
Print#1,Text1.Text
Close#1
End Sub
、
Private Sub Command1_Click()
Open “out.txt” For Outpit As#1
Print#1,Text1.Text
Close#1
End Sub
、
Private Sub Command1_Click()
Open “out.txt” For Append As#1
Print#1,Text1.Text
Close#1
End Sub
、
Private Sub Command1_Click()
Open “out.txt” For Random As#1
Print#1,Text1.Text
Close#1
End Sub
答案:
27、【
单选题
】 为计算1+3+5+……+99的值,某人编程如下
k=1
s=0
While k<=99
k=k+2 : s=s+k
Wend
Print s
在调试时发现运行结果有错误,需要修改。下列错误原因和修改方案中正确的是( )
[2分]
、
While …Wend循环语句错误,应改为For k=1 To 99 …Next k
、
循环条件错误,应改为Whlie k<99
、
循环前的赋值语句k=1错误,应改为k=0
、
循环中两条赋值语句的顺序错误,应改为s=s+k : k=k+2
答案:
28、【
单选题
】 下面程序在调试时出现了死循环
Private Sub Command1_Click()
n=InputBox(“请输入一个整数”)
Do
If n Mod 2=0 Then
n=n+1
Else
n=n+2
Else If
Loop Until n=1000
End Sub
下面关于死循环的叙述中正确的是( )
[2分]
、
只有输入的n是偶数时才会出现死循环,否则不会
、
只有输入的n是奇数时才会出现死循环,否则不会
、
只有输入的n是大于1000的整数时才会出现死循环,否则不会
、
输入任何整数都会出现死循环
答案:
29、【
单选题
】 在窗体上有1个名称为CommonDialog1的通用对话框和1个名称为Command1的命令按钮,以及其他一些控件。要求在程序运行时,单击Command1按钮,则显示打开文件对话框,并在选择或输入了1个文件名后,就可以打开该文件。以下是Command1_Click事件过程的两种算法
算法1:
Private Sub Command1_Click()
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As#1
End Sub
算法2:
Private Sub Command1_Click()
CommonDialog1.ShowOpen
IfCommonDialog1.FileName<>””Then
Open CommonDialog1.FileName For Input As#1
End If
End Sub
下面关于这两种算法的叙述中正确的是()
[2分]
Private Sub Command1_Click()
Dim str As String, s As String, k As Integer
s=Text1
Str=””
For k=List1.ListCount-1 to 0 Step-1
If InStr(List.List(k),s)>0 then
str=str&List.List(k)&” ”
End If
Next k
If str=””Then
Text2=”没有匹配的项目”
Else
Text2=str
End If
End Sub
程序运行时,在Text1中输入“京”,单击命令按钮,则在Text2中显示的内容是( )
[2分]
、
京
、
北京 南京
、
南京
、
没有匹配的项目
答案:
31、【
单选题
】 在窗体上画1一个名称为Command1的命令按钮,并编写以下程序
Private Sub Command1_Click()
Print fun(“ABCDEFG”)
End Sub
Function fun(st As String) As String
stlen=Len(st)
temp=””
For k
fun=temp
End Function
程序运行时,单击命令按钮,则窗体上显示的是( )
[2分]
、
Priate Sub Form_DragDrop(Source As Control,X As Single,Y As Single banana.Move Picture1.Left+X,Picture1.Top+Y)
End Sub
、
Private Sub banana _DragDrop(Source As Control,X As Single,Y As Single )
Source.Move Picture1.Left+X.Picture1.Top+Y
End Sub
、
Private Sub Picture1_DragDrop(Source As Control,X As Single,Y As Single )
Source.Move Picture1.Left+X.Picture1.Top+Y
End Sub
、
Private Sub Picture1_DragDrop(Source As Control,X As Single,Y As Single )
banana.Move banana.Left+X, banana.Top+Y
End Sub
答案:
33、【
单选题
】 在窗体上画1个名称为Command1的命令按钮,然后编写如下事件过程
Option Base 1
Pribate Sub Command1_Click()
Dim a(5.5) As Integer
For i=1 To 5
a(I,j)*5\10
Next j
Next i
S=0
For i=1 To 5
S=s+a(i,i)
Next i
Print s
End Sub
程序运行后,单击命令按钮,输出结果是( )
[2分]
、
Private Sub Text1__KeyPress(KeyAscii AS Integer)
If KeyAscii=13 Then ‘回车符的ACSII码是13
a=Val(Text1)
If a>=0 or a<=100 Then
Text2.SetFocus
Else
Text1. SetFocus ; MsgBox(“分数错”)
End If
End If
End Sub
、
Private Sub Text1__KeyPress(KeyAscii AS Integer)
If KeyAscii=13 Then ‘回车符的ACSII码是13
a=Val(Text1)
If a>=0 And a<=100 Then
Text1.SetFocus
Else
Text2. SetFocus ; MsgBox(“分数错”)
End If
End If
End Sub
、
Private Sub Text1__KeyPress(KeyAscii AS Integer)
If KeyAscii=13 Then ‘回车符的ACSII码是13
a=Val(Text1)
If a<0 And a>100 Then
Text2.SetFocus
Else
Text1. SetFocus ; MsgBox(“分数错”)
End If
End If
End Sub
、
Private Sub Text1__KeyPress(KeyAscii AS Integer)
If KeyAscii=13 Then ‘回车符的ACSII码是13
a=Val(Text1)
If a>=0 And a<=100 Then
Text2.SetFocus
Else
Text1. SetFocus ; MsgBox(“分数错”)
End If
End If
End Sub
答案:
35、【
单选题
】 在窗体上画2个命令按钮,名称分别为Command1、command2,并编写如下程序
Const n=5,m=4
Dim a(m,n)
Private Sub Command1_Click()
K=1
For i=1 To m
For j=1 To n
a(i,j)=k
k=k+1
Next j
Next i
Private Sub Command2_Click()
Summ=0
For i=1 To m
For j=1 To n
If i=1 Or i=m Then
Summ=summ+a(i,j)
Else
If j=I Or j=n Then
Summ=summ+a(i,j)
End If
End If
Next j
Next i
Print summ
End Sub
过程Command1_Click()的作用是二维数组a 中存放1个 m行n列的矩阵;过程Command2_Click()的作用是( )
[2分]