上面的代码打错了一个字母,现已改正。它的特点是效率高,只要循环9000(9千)次,而用For i=10001 to 99999的,要循环89999(近9万)次。
Private Sub Command1_Click()
Dim i As Long, j As Long, s As Long
List1.Clear
For i = 1 To 9
For j = 0 To 999
k = 10001 * i + j * 10
If k Mod 3 = 2 Then '这一行有改动,改为k
List1.AddItem k
s = s + k
End If
Next j
Next i
List1.AddItem "总和 = " & s & " 个数 = " & List1.ListCount
End Sub