I am trying to seperate the code below into one sub routine and one function. Specifically a boolean function that does the number check. I am still learning how to use sub procedures and functions and am not sure where to do the seperation. Any advice would be helpful. I've tried and when I break it up, the functionality goes crazy.
If IsNumeric(txtLower.Text) And IsNumeric(txtUpper.Text) Then
If CInt(txtLower.Text) < CInt(txtUpper.Text) Then
Dim intLower As Integer ' lower bound input
Dim intUpper As Integer ' upper bound input
Dim intNumber As Integer ' used to check for prime
Dim intPrimeCounter As Integer ' counter
intLower = txtLower.Text
intUpper = txtUpper.Text
Do While intLower <= intUpper
intNumber = 2
intPrimeCounter = 0
Do While intNumber < intLower
If (intLower Mod intNumber) = 0 Then
intPrimeCounter += 1
End If
intNumber += 1
Loop
If intPrimeCounter = 0 Then
txtResults.AppendText(intLower & Environment.NewLine)
End If
intLower += 1
Loop
Else
MsgBox("Upper Bound Must be Greater than Lower Bound ")
End If
Else
MessageBox.Show(Text:="Enter a Positive Numeric Value", _
caption:="Input error - Prime Numbers")
End If
End Sub