Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
Dim checker As Boolean = True
Dim prompt As String = String.Empty
Dim people As Integer
Integer.TryParse(txtPeople.Text, people)
people = ValidatePeople(txtPeople.Text)
If people = 0 Then
prompt = prompt & "Invalid number of people "
checker = False
End If
If checker = False Then
MessageBox.Show(prompt, "Error")
End If
Private Function ValidatePeople(ByVal people As Integer) As Integer
If people > 20 OrElse people < 1 OrElse Not IsNumeric(people) OrElse Not String.IsNullOrWhiteSpace(people) Then
Return people = 0
Else
Return people
End If
End Function
Trying to make the value entered to be checked as not empty, is numeric and only returns value when the value is not less then 1 or more then 20. But when I leave it empty ( supposely the messagebox will come out but it dint) but it just crashes.Also, when i enter a valid number, the message box displays error . Was hoping someone could point out my mistake . Thanks in advance