23) Design a form and write a program in visual basic to input name, sex, height, age, weight of a person using input boxes. Print name of person to output box. Only when person full fill the following condition. (1) his sex must be male (2) his age must be 18 to 21 years (3) his height must be 165 cm or more and (4) his weight must be 75 kg or less.


Private Sub Command1_Click()
Dim name, sex As String, height, age, weight As Integer
name = InputBox("Enter Name ")
sex = InputBox("Enter Sex (M/F)")
height = InputBox("Enter Height (Cm)")
age = InputBox("Enter Age ")
weight = InputBox("Enter Weight")
If sex = "M" Or sex = "m" Then
    If age >= 18 And age <= 21 Then
        If height >= 165 Then
            If weight <= 75 Then
                MsgBox ("Name " & name)
            End If
        End If
    End If
End If
End Sub




Comments are closed.

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: