i have to create application that ask user to input Lower bound and upper bound (both intger) greater than 1 and determins all of the prime numbers within the specified bounds, inclusive. and write function procedure prime that returns True if a number is prime. False otherwise. i also should use error provider.

i wrote these 2.. but both are not working ?? :'(
i don't know where is my mistake
any help plz ?? :idea:

i have to submit my project tomorrow :(

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim i As Integer
Dim a As Integer
Dim b As Integer

For i = a To b

Next

End Sub
Function Prime(ByVal b As Integer) As Boolean
Dim i As Integer
Dim a As Integer
a = TextBox1.Text
b = TextBox2.Text

For i = a To b - 1
If b Mod a = 0 Then
Prime = False
Exit Function
End If

Next i
Prime = True
Return a
End Function
End Class

Public Class Form1
Dim i As Integer
Dim n As Integer
Dim a As Integer
Dim b As Integer
Dim c As Integer
Private Sub btnCalP_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalP.Click

a = Val(txtLoBo.Text)
b = Val(txtUpBo.Text)

For i = a To b
If b Mod 2 <> 0 Then
End If
Next

End Sub

Function Prime(ByVal a As Integer, ByVal b As Integer) As Integer

Dim flag As Boolean = True

If a Mod 2 <> 0 Then
For c = 2 To b - 1
If a Mod c = 0 Then
flag = False

Else
flag = True
End If
Next
end if

Return flag = True
Return flag = False
End Function

End Class

2
Contributors
5
Replies
6
Views
10 Years
Discussion Span
Last Post by Jx_Man

first you must know the type and patern of prime number :
Hope the following code is solved your problem :

``````Private Sub PrimeNumber(ByVal Low As Integer, ByVal Up As Integer)
Dim i As Integer
For i = Low To Up
If (i = 2) Or (i = 3) Or (i = 5) Or (i = 7) Then
Else
If (i Mod 2 <> 0) And (i Mod 3 <> 0) And (i Mod 5 <> 0) And (i Mod 7 <> 0) Then
End If
End If
Next
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListPN.Items.Clear()
End Sub``````

Hope this helps.
don't forget to give feedback

Thaaaaaaaaaaaaaaaaaaaaaaaaaaaanks 4 ur helping.. :)

it's work now :)

you're welcome :)
don't forget to mark this thread solved

you're welcome :)
don't forget to mark this thread solved

i have problem with the result

if i enter 1 , 199

it give all prime numbers between to thses nums

but it give also 200 which is even num. and it's not between 1 and 199 ??

i have tried it. and i don't get result 200.just between 1-199.