作业帮 > 综合 > 作业

VB程序 for循环语句问题 从1,2,3,……,一直写到200,一共写了多少个数码3?

来源:学生作业帮 编辑:百度作业网作业帮 分类:综合作业 时间:2024/07/14 07:58:41
VB程序 for循环语句问题 从1,2,3,……,一直写到200,一共写了多少个数码3?
请用for语句
VB程序 for循环语句问题 从1,2,3,……,一直写到200,一共写了多少个数码3?
Option Explicit
Private Sub Command1_Click()
Dim i As Integer
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim n As Integer
n = 0
For i = 1 To 200
a = i \ 100
b = i \ 10 Mod 10
c = i Mod 10
If a = 3 Then
n = n + 1
End If
If b = 3 Then
n = n + 1
End If
If c = 3 Then
n = n + 1
End If
Next i
Print n
End Su