在列表框中显示指定范围内的素数。用 VB, 谢谢!
1个回答
展开全部
Private Sub Command1_Click()
Dim iNumA as Long, iNumB as Long
iNumA = Val(Text1.Text) '上限
iNumB = Val(Text2.Text) '下限
Dim i as Long,m as Long
For i = iNumA to iNumB
For m = 2 to Int(i/2)
if i mod m = 0 then Goto iNext
Next
List1.Additem i
iNext:
Next
End sub
纯手输,你自己测试吧!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询