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 IntegerListBox1.Items.Add(Prime(Val(TextBox1.Text))
For i = a To bListBox1.Items.Add(i)
Next
End Sub
Function Prime(ByVal b As Integer) As Boolean
Dim i As Integer
Dim a As Integer
a = TextBox1.Text
b = TextBox2.TextFor i = a To b - 1
If b Mod a = 0 Then
Prime = False
Exit Function
End IfNext i
Prime = True
ListBox1.Items.Add(i)
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.Clicka = Val(txtLoBo.Text)
b = Val(txtUpBo.Text)
lstPN.Items.Add(Prime(Val(txtLoBo.Text), Val(txtUpBo.Text)))For i = a To b
If b Mod 2 <> 0 Then
lstPN.Items.Add(c)
End If
NextEnd Sub
Function Prime(ByVal a As Integer, ByVal b As Integer) As Integer
Dim flag As Boolean = TrueIf a Mod 2 <> 0 Then
For c = 2 To b - 1
If a Mod c = 0 Then
flag = False
Else
lstPN.Items.Add(c)
flag = True
End If
Next
end ifReturn flag = True
Return flag = False
End FunctionEnd Class