Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label5.Text = ""
If TextBox1.Text = "" Then
Label5.Text = "1. sayıyı yazınız.."
ElseIf TextBox2.Text = "" Then
Label5.Text = "2. sayıyı yazınız.."
Else
ListBox1.Items.Clear()
Dim gst As Integer = 0
For df = Val(TextBox1.Text) To Val(TextBox2.Text)
Dim sayı, asal As Integer
sayı = df
For x As Integer = 1 To sayı
If sayı Mod x = 0 Then asal = asal + 1
Next
If asal = 2 Then
ListBox1.Items.Add(sayı)
gst = gst + 1
Label1.Text = gst.ToString
End If
asal = 0
Next
End If
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Asc(e.KeyChar) <> 8 Then
e.Handled = Not IsNumeric(e.KeyChar)
End If
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If Asc(e.KeyChar) <> 8 Then
e.Handled = Not IsNumeric(e.KeyChar)
End If
End Sub
End Class
KADİR SELEN