Public Class Form1 Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim n, i, s As Integer n = CInt(TextBox1.Text) 'Is tere an integer number i between 1 and n such that n is divisible by i s = Math.Sqrt(n) + 1 'added 1 to eliminate possible rounding error For i = 2 To s If n Mod i = 0 Then 'i is such a divisor so n is not prime Label1.Text = CStr(n) & " is not prime" Return 'We accomplished the task End If Next 'There are no such divisors so n is prime Label1.Text = CStr(n) & " is prime" End Sub Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click End Sub End Class