当前位置:编程学习 > VB >>

vb编程一直出现错误,这个错误怎么解决?

求1-1000之间的素数个数及他们的和,还有平均数
代码如下
结果错误,请帮我找找原因
Private Sub Form_Click()
    Dim x As Integer, i As Integer, s As Single, n As Single, anv As Single
    s = 0: n = 0
    For x = 1 To 1000
      For i = 2 To Sqr(x)
       If x / i <> x \ i Then
        Print Tab(7 * (x Mod 6) + 2); x;
        s = s + x
        n = n + 1
         Exit For
     End If
     Next i
    
     Next x
     anv = s / n
    
     MsgBox "素数个数为:" & n & "素数和为:" & s & "平均值为:" & anv
 
End Sub
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,