Please can someone help correct this code.Wanted the programme to display reject when number below 18Code:Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim age As Integer Dim height As Double Dim weight As Double Dim name As String Dim status As String name = Txtname.Text age = txtage.Text height = txtheight.Text weight = txtweight.Text If age >= 18 And age <= 60 Then If height >= 170 And height <= 2000 Then If weight >= 60 And weight <= 80 Then status = " prceed " Else status = " Reject " End If End If End If txtoutput.Text = " name: " & name & vbCrLf & " Age: " & age & vbCrLf & _ " height: " & height & vbCrLf & _ " weight: " & weight & vbCrLf & " Status: " & status End Sub End Class
is entered on the 'Age' textbox
Last edited by Vswe; 03-13-2010 at 02:54 AM. Reason: Use Code tags when posting code
The most simple way us just to add two more Else blocks, your current Else block is corresponding with the "weight If statement". Another solution would be to add all three conditions from the If statements in the same if statement by using "And".
serious!
Just add an else clause for this: If age >= 18 And age <= 60 Then
That is:
If age >= 18 And age <= 60 Then
'existing code
Else
'display reject
End If
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks