| | |
Prime Number Function
Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2006
Posts: 8
Reputation:
Solved Threads: 0
I'm trying to write a function that checks for prime numbers and returns true if a number is prime. Something simple, i'm just a beginner. Here's what I have, does it make sense..if not any input would be appreciated.
Function IsPrime(ByVal dblCheck AsDouble) AsBoolean
Dim intNumber As Integer
For intNumber = 2 To dblCheck - 1
If dblCheck Mod intNumber = 0 Then
IsPrime = False
Exit Function
End If
Next intNumber
IsPrime = True
'return prime numbers
Return dblCheck
End Function 'IsPrime
Function IsPrime(ByVal dblCheck AsDouble) AsBoolean
Dim intNumber As Integer
For intNumber = 2 To dblCheck - 1
If dblCheck Mod intNumber = 0 Then
IsPrime = False
Exit Function
End If
Next intNumber
IsPrime = True
'return prime numbers
Return dblCheck
End Function 'IsPrime
•
•
•
•
I'm trying to write a function that checks for prime numbers and returns true if a number is prime. Something simple, i'm just a beginner. Here's what I have, does it make sense..if not any input would be appreciated.
Function IsPrime(ByVal dblCheck AsDouble) AsBoolean
Dim intNumber As Integer
For intNumber = 2 To dblCheck - 1
If dblCheck Mod intNumber = 0 Then
IsPrime = False
Exit Function
End If
Next intNumber
IsPrime = True
'return prime numbers
Return dblCheck
End Function 'IsPrime
*Voted best profile in the world*
![]() |
Similar Threads
- C++ prime number program help (C++)
- My prime Number generator (Python)
- Prime Numbers - Help its for college (Visual Basic 4 / 5 / 6)
- Print Max Prime Number??? (C++)
- Recursive prime number f(x) (C)
Other Threads in the VB.NET Forum
- Previous Thread: guys i really need your help in this one
- Next Thread: how to connect access with vb.net
Views: 7401 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
"crystal .net .net2005 2008 access add application array assignment basic box button buttons center class click code combo convert cpu data database datagrid datagridview design designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees error excel exists firewall function image images isnumericfuntioncall listview login map math memory mobile module msaccess mssqlbackend mysql navigate net opacity page pan picturebox port print printing printpreview problem record refresh regex reports" reuse right-to-left save savedialog search serial socket sorting sql sqldatbase storedprocedure string structures studio temp textbox timer txttoxmlconverter upload useraccounts usercontol usercontrol vb vb.net vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet vista visual visualbasic visualbasic.net visualstudio2008 web wpf xml






