473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Primes Numbers

Hallo
I have a problem. I want to make a program in Visual Basic 2005. It should find and print prime numbers. I do not know how to make it. Can someone helps me.

Thanks
Nov 12 '06 #1
4 2645
willakawill
1,646 1GB
Hallo
I have a problem. I want to make a program in Visual Basic 2005. It should find and print prime numbers. I do not know how to make it. Can someone helps me.

Thanks
Hi. Can you tell us please if your difficulty is in programming or in working out an algorithm to generate prime numbers?

BTW you may get a more accurate answer in the .NET forum as you are using vb.NET.
Nov 12 '06 #2
albertw
267 100+
Hallo
I have a problem. I want to make a program in Visual Basic 2005. It should find and print prime numbers. I do not know how to make it. Can someone helps me.

Thanks
hi
don't know about 2005, but in VB6 you may use this example:
create a form with a listbox (List1)

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Load()
  3. Dim prime As New Collection
  4. prime.Add 1                         'actually 1 is a special number
  5. prime.Add 2                         '2 is the first real prime
  6. For i = 3 To 1000                   'start searching from 3 to whatever number (1000)
  7. NoPrime = False                     'assume primenumber
  8.     For dev = 2 To prime.Count - 1  'try to devide actuale number by all other primes
  9.     If i Mod prime(dev) = 0 Then    'if devision has no remains then no prime
  10.        NoPrime = True
  11.        Exit For
  12.     End If
  13.     Next dev                        'if i is a prime, add to collection
  14.     If NoPrime = False Then prime.Add i
  15. Next i
  16.  
  17. For i = 1 To prime.Count - 1        'if all are done, put into the list
  18. List1.AddItem prime(i)
  19. Next i
  20.  
  21. End Sub
  22.  
  23.  
Nov 12 '06 #3
Hi. Can you tell us please if your difficulty is in programming or in working out an algorithm to generate prime numbers?

BTW you may get a more accurate answer in the .NET forum as you are using vb.NET.

I know the algorithm but I have problem in programming
Nov 15 '06 #4
albertw
267 100+
I know the algorithm but I have problem in programming
guess your in the wrong forum then.... :(
Nov 15 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

32
by: someone else | last post by:
hi all I'm a newbie to this group. my apologies if I break any rules. I've wrote a simple program to find the first 1,000,000 primes, and to find all primes within any range (up to 200 *...
104
by: fieldfallow | last post by:
Hello all, Is there a function in the standard C library which returns a prime number which is also pseudo-random? Assuming there isn't, as it appears from the docs that I have, is there a...
5
by: Carramba | last post by:
theorem states that: Integer n is prime if and only if (x +1)^n ≡ x^n +1 (mod n) in Z. so I testing it, but values doesn't match ... and I don't se why.. I guess :) it's some thing wrong in...
7
by: Umesh | last post by:
Write a program for this purpose. Note: If the difference of two consecutive primes is 2, they are called twin primes. e.g. 3 & 5, 11 & 13 etc.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.