Page 1 of 1

## 1 Replies - 6063 Views - Last Post: 10 November 2007 - 05:19 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=37147&amp;s=3851c742f60b3fc296a304bf5fb9ce56&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 jason7361

Reputation: 2
• Posts: 8
• Joined: 07-October 07

Posted 10 November 2007 - 01:27 AM

I am writing a project to find prime number between specific range
here is the example:

i use some for loop to search the number
and it can show me which number is prime number or not
but i don't know how to put my prime number into the list
here is what i can get so far.

can anyone help me? Thanks a lot
here are my code:

```	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Double
Dim b As Double
Dim c As Double
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)

For a = a To b Step 1

For c = 2 To a - 1 Step 1

If a Mod c = 0 Then

Exit For

End If

Next
Next

End Sub

```

can anyone tell me how to fix it?

This post has been edited by jayman9: 10 November 2007 - 02:57 PM

Is This A Good Question/Topic? 0

### #2 Mr Ed

Reputation: 1
• Posts: 19
• Joined: 09-November 07

Posted 10 November 2007 - 05:19 AM

```	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Double
Dim b As Double
Dim c As Double
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)

For a = a To b Step 1
For c = 2 To a - 1 Step 1
If a Mod c = 0 Then
Exit For
Else
Exit For
End If
Next
Next
End Sub

```

Quote

can anyone tell me how to fix it?

Add the else and exit for