So zum Beispiel:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim von As Integer = txtVon.Text
Dim bis As Integer = txtBis.Text
Dim i As Integer
Dim j As Integer
txtOutput.Text = ""
For i = von To bis
If isPrime(i) Then
txtOutput.Text += CType(i, String) + ", "
End If
Next
End Sub
Function isPrime(ByVal zahl As Integer)
Dim x As Integer
Dim p As Boolean = True
For x = 2 To Math.Sqrt(zahl)
If zahl Mod x = 0 Then
p = False
End If
Next
If zahl = 1 Then
p = False
End If
Return p
End Function