31、【
填空题
】 [原创]下面的程序执行时在Text1文本框中输入一个数,鼠标点击按钮后,在Text2文本框中显示相应的数。
Private Sub Command1_Click( )
Dim k as integer
k=Val(Text1.text)
Text2.text=Str(k mod 5\2)
End Sub
当在Text1文本框中输入9,则在Text2文本框中显示的值是:
。
[每空1分]
答案:["1"]
32、【
填空题
】 下列VB程序运行时在文本框Text1中输入85,单击命令按钮Command1后,文本框Text2中输出X的值,那么程序划线入应填入语句:
,Text2中显示的是
。
Private Sub Command1_Click( )
Dim s as Integer
Dim x as String
s=Val(Text1.text)
If s>=90 then
X=”A”
ElseIf s>=60 then
X=”B”
Else
X=”C”
End if
End Sub
[每空2分]
答案:["Text2.text=X","B"]
33、【
填空题
】 编写计算1/2+2/3+3/4+4/5的程序如下:[把选择题改编成程序填空题]
Private Sub Command1_Click( )
Dim i,n as integer
Dim sum, x as Double
Sum=0
①
For i=1 to 5
②
n=n+1
sum=sum+x
Next i
Text1.text=Str(sum)
End Sub
请在程序画线处填上合适的语句
[每空2分]
Private sub command1_click( )
Dim a,b As integer
Dim temp As integer
Dim i As integer
a=Val(Text1.text)
b=Val(Text2.text)
If a>b then
temp=a:a=b:b=temp
End if
For i=1 to a
If ________________then list1.additem i
Next i
End sub
(1)此程序主要采用了
算法。
(2)请在划线处填入合适的代码
。
[每空2分]
Private Sub Command_Click( )
Dim a(1 to 10) as Integer
Dim n as ①
Dim i,lena,j as integer
n=Text1.text
lena=Len(n)
For i=1 to lena ‘按位取出各位数字
a(i)=Val(Mid(n,1,i)) ②
Next i
For i=1 to lena-1
For j=lena to i+1 Step -1
If ③ then
t=a(j):a(j)=a(j-1):a(j-1)=t
End If
Next j
Next i
For i=1 to lena
Text2.text=text2.text+str(a(i))
Next i
End Sub
(1)程序①中划线处应填入
。
(2)程序②中划线处语句有错,应改为:
。
(3)程序③中划线处应填入
。
[每空2分]