VB:求1000以内的质数 Private Sub Command1_Click() Dim m%, i%, p%, k%, n% For m = 2 To 1000 '求1000以内的质数,2是最小的质数 p = 1 k = Int(Sqr(m)) For i = 2 To k If m Mod i = 0 Then p = 0 Exit For End If Next i If p = 1 Then Print Tab((n Mod 10) * 5 + 2); m; n = n + 1 End If Next m End Sub