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

OrElse Not IsNumeric(people) OrElse Not String.IsNullOrWhiteSpace(people) Then

It has no justification in the Function ValidatePeople().
You should did it before calling the function.
Like

If (not IsNumeric(txtpeople.Text)) or String.IsNullOr WhiteSpace(txtpeople.Text) Then
    MessageBox.Show("Please input a valid number withen 1 and 20.)
    Exit Sub
End If

people = ValidatePeople(Val(txtPeople.Text))

And your function is

  Private Function ValidatePeople(ByVal people As Integer) As Integer
            If (people > 20) Or (people < 1) Then
                Return 0
            Else
                Return people
            End If
        End Function
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.