作者fumizuki (蒙面加菲狮)
看板Visual_Basic
标题Re: [VBA ] 请问一下关於一个回圈还有.....的问题
时间Sun Jun 24 12:39:04 2007
Public Sub ShowPrime()
MsgBox "1到" & 100 & "之间的质数有:[" & EnumPrime(100) & "]", _
vbInformation
End Sub
Public Function IsPrime(ByVal number As Long) As Boolean
If number <= 1 Then IsPrime = False: Exit Function
If number = 2 Or number = 3 Or number = 5 Or number = 7 Then
IsPrime = True: Exit Function
End If
Dim i As Long
For i = 2 To Sqr(number)
If number Mod i = 0 Then IsPrime = False: Exit Function
Next
IsPrime = True
End Function
Public Function EnumPrime(ByVal n As Long) As String
Dim i As Long, count As Long, s As String
For i = 1 To n
If IsPrime(i) Then
If s <> "" Then s = s & ","
s = s & i
End If
Next
EnumPrime = s
End Function
--
▃▅▇▆▄ ▆▂▃ `
逝去感情如何能留住,半点痴情遗留殊不易,██▅▇▄▃ ▇▃▂" .
█████████▃i ▁▄▇
更多凄凄惨惨的遭遇…………██▆▃ █▅▆▃ˍ▄*
◢ ▂█▄▇▅▂▌.
我不知道,王~八~蛋~~! ▂▆███ █▄▃ 。fumizuki。Check。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 123.194.224.174
1F:推 mick1031:请问一下..Isprime是VBA方法吗..为什麽我用VBA说明找不到 06/24 16:21
2F:推 fumizuki:我都在下面列出IsPrime了 怎麽会是VBA提供的@@ 06/24 18:10
3F:推 mick1031:所以..不懂..IsPrime是什麽= =?另一种语言..?抱歉....... 06/24 21:01
4F:→ FantasyRyu:楼上 Public Function IsPrime =_=a 06/24 22:23
5F:→ FantasyRyu:哦哦,我猜他还在练写console,没学到自定函数 06/24 22:25