作业帮 > 综合 > 作业

VB编程求1-1000以内任意两数间的所有质数!

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/18 13:09:02
VB编程求1-1000以内任意两数间的所有质数!
就是要在窗体内任意输入两个自然数(均小于1000)显示这两个数之间所有质数.
Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim i As Integer,j As Integer
a = Text1
b = Text2
If a > b Then
c = a
a = b
b = c
End If
c = 0
For i = a To b
For j = 2 To i - 1
If i Mod j = 0 Then
Exit For
End If
Next j
If j = i Then Print i
Next i
End Su