编写“鞋码换算”程序,实现如下功能:在文本框 Text1 中输入脚长 n(单位:厘米),单击“换算”按钮 Command1,在标签 Label1 中显示相应鞋码,同时在列表框 List1 中显示与脚长对应的标准鞋码表。程序运行界面如图所示。
(1)
如图所示,能生成运行界面中列表框的控件是( )
A .
B .
C .
D .
(2)
实现上述功能的VB程序如下,请在划线处填写合适的代码。Private Sub Command1_Click()Dim n As Single, i As, c As IntegerList1.Clearn = Val(Text1.Text)If n - Int(n) > 0.5 Then ‘n小数部分大于0.5的加1,0.5及以下的加0.5End If c = n * 2 - 10Label1.Caption = "适合你的鞋码为:" + Str(c)For i =To n+2 step 0.5 c = i*2-10 If Int(i) = i Then List1.AddItem Str(i) + " " + Str(c) Else List1.AddItem Str(i) + " " + Str(c) End IfNext iEnd Sub
答案: B
【1】Single【2】n=int(n)+1 Else n=int(n)+0.5【3】n-2