更新时间2018-03-06 21:33:42
程序运行时,在文本框 Textin 中输入正整数n。单击命令按钮Commandl后,统计 1至 n 的整数中包含数字 2的整数个数,并在文本框Textout 中输出结果,若n=20,有2、12和20三个整数包含数字2,则文本框Textout 中输出“3”。
请在划线上填入合适的代码。
Private Sub Command1_Click()
Dim i as Long
Dim n as Long
Dim s as Long
Dim k as Boolean
Dim t as Long
s = 0
n = Val(Textin.Text)
For i = 1 To n
k = False
____(1)______
Do While Not k And t > 0
If t Mod 10 = 2 Then ____(2)_______
t = t 10
Loop
If ___(3)_____ Then
s = s + 1
List1.AddItem Str(i)
End If
Next i
Textout.Text = Str(s)
End Sub
For i = 1 To n
k = False
t = i
Do While Not k And t > 0
If t Mod 10 = 2 Then k = True
t = t 10
Loop
If k = True Then
s = s + 1
List1.AddItem Str(i)
End If
Next i
上一篇:如何查找有关移民的数据
下一篇:c语言中次方怎么表达