题型:填空题 题类:模拟题 难易度:普通
浙江省杭州市2015年高考信息技术模拟卷10
现要求编写VB程序(运行界面图所示),实现如下功能:在文本框Text1中输入一个三位数整数,单击“求解”按钮Command1,在文本框Text2中显示重新组合后的最大三位数整数。某同学按此要求编写的程序如下,其中函数max(x)用于求解最大三位数整数,但加框处代码有错,请改正。
① ②
Function max(x As Integer) As Integer
Dim a As Integer, b As Integer, c As Integer, t As Integer
a = x \ 100
b = (x \ 10) \ 10 ' ①
c = x mod 10
If a < b Then t = a: a = b: b = t
If a < c Then t = a: a = c: c = t
If b < c Then t = c: c = b: b = t
max = c* 100 + b * 10 + a ' ②
End Function
Private Sub Command1_Click()
Dim n As Integer, y As Integer
n = Val(Text1.Text)
y = max(n)
Text2.Text = Str(y)
End Sub
试题篮