求VB高手:键盘输入一个正整数,找出大于或等于该数的第一个素数.怎么编写程序代码啊?

лл~!
2024-11-17 22:05:55
推荐回答(1个)
回答1:

Private Sub Command1_Click()
Dim i%
Randomize
For i = 1 To 30
Print Int(Rnd * 100 + 1);
If i Mod 10 = 0 Then Print
Next
End Sub

Private Sub Command2_Click()
Dim i%, n%, m As Boolean
n = Val(InputBox("输入一个正整数吧!"))
Print "正整数:"; n
Do
m = False
For i = 2 To n - 1
If n Mod i = 0 Then m = True: Exit For
Next
If m = False Then Exit Do
n = n + 1
Loop
Print "大于前氏或等于该数伍铅的第一个素数:"腔悔好; n
End Sub