编写一个找出100以内所有素数的VB程序,代码错误,不知道哪错了,会的人请帮看下。

2024-12-17 05:49:54
推荐回答(1个)
回答1:

Private Sub form_Load()'这里改了
Dim n As Integer, k As Integer
Dim st As String, js As Integer
For n = 2 To 100
For k = 2 To n - 1
If n Mod k = 0 Then Exit For
Next k
If k > n - 1 Then
st = st & Right("" & Str(n), 3)
js = js + 1
If js Mod 5 = 0 Then st = st + Chr(13) + Chr(10)
End If
Next n
txtPn.Text = st'这里不知道txtPn是否存在,我改了后是可以运行的。朋友
End Sub