Ch-9 Programming
Ch-9 Programming
2025
Ch-9
Sequential Programs:
Program 1. WAP a program in VB to accept the length and breadth from the user through the text
boxes. Calculate the area of rectangle and display in 3rd textbox on click of a button"Calculate Area".
Dim L, B, Ar As Integer
L = Val(Text1.Text)
B = Val(Text2.Text)
Ar = L * B
Text3.Text = Ar
End Sub
Program 2.WAP to accept a value of speed and time from the user.Calculate the distance covered and
show the output in the 3rd text box on the click of a button "Calculate Distance".
S = Val(Text1.Text)
T = Val(Text2.Text)
Dis = S * T
Text3.Text = Dis
End Sub
Program 3. WAP to accept a number in the 1st textbox. Claculate the square and cube of the same
number in 2nd and 3rd textboxes respectively on the click of a button "Calculate".
Dim N, S, C As Integer
N = Val(Text1.Text)
S=N^2
C=N^3
Text2.Text = S
Text3.Text = C
End Sub
***************************************************************************
Conditional Programs:
1.If condition
If (Condition) Then
----------
---------
End If
2. If Then ………..Else
If (Condition ) Then
--------- True case
--------
Else
---------
End If
3.If Then…………ElseIf
If (Cond1) Then
--------------
ElseIf(Cond2) Then
-----------------
ElseIf(Cond3) Then
------------------
Else
-----------------
End If
*****************************************************************
Program 4. WAP to accept the age from the user in 1st text box. Check his eligibility for voting on the
click of a button “Check”.
Age = Val(Text1.Text)
Else
End Sub
Program 5. WAP to accept a number from the user through textbox. Check whether the number is odd
or even on the click of a button “Check”.
Dim N As Integer
N = Val(Text1.Text)
If (N Mod 2 = 0) Then
Else
End If
End Sub
Program 6. WAP to accept a number from the user through textbox. Check whether the number is
divisible by both 2 and 5 on the click of a button “Check”.
Dim N As Integer
N = Val(Text1.Text)
Else
End If
End Sub
Program 7. WAP to accept percentage from the user through text box and show the remarks in
message box based on the following criteria.
Percent<40: “Failed”
Percent>=40 and <50 “Passed”
Dim P As Single
P = Val(Text1.Text)
MsgBox ("Good")
MsgBox ("Average")
MsgBox ("Passed")
Else
MsgBox ("Failed")
End If
End Sub