Save Project As Labex1. Using If Then Else Statement, Write A Program in VB That Will Accept A Number
Save Project As Labex1. Using If Then Else Statement, Write A Program in VB That Will Accept A Number
Save Project As Labex1. Using If Then Else Statement, Write A Program in VB That Will Accept A Number
Galvez
BSA 4-1
1. Save project as LabEx1. Using If Then Else statement, write a program in VB that will accept a number
value in a TextBox and assign it to a variable and identify if the given number is an odd or even
number.
Public Class Form1
Dim Number As Integer
Private Sub btnevaluate_Click(sender As Object, e As EventArgs) Handles
btnevaluate.Click
Number = txtno.Text
If Number > 0 Then
lblPorN.Text = "Positive"
ElseIf Number < 0 Then
lblPorN.Text = "Negative"
Else
lblPorN.Text = "Neither Positive nor Negative"
End If
2. Save project as LabEx2. Using If Then Else statement, write a program in VB that will accept a character
value in a variable and identify if the given character is vowel or consonant. The program should
identify both capital and small letters.
Public Class Form1
Dim Letter As Char
Private Sub btnevaluate_Click(sender As Object, e As EventArgs) Handles
btnevaluate.Click
Letter = txtLetter.Text
If Letter = "A" Or Letter = "a" Or Letter = "E" Or Letter = "e" Or Letter = "I"
Or Letter = "i" Or Letter = "O" Or Letter = "o" Or Letter = "U" Or Letter = "u" Then
lblVorC.Text = "Vowel"
Else
lblVorC.Text = "Consonant"
End If
End Sub
End Class
3. Save project as LabEx3. Using If Then ElseIf statement, write a program in VB that will assign the value
50,000 to a variable called Amount and a variable that will hold the value for the mode of payment.
The program will then identify the mode of payment. The program will then identify the mode of
payment as the following.
Mode Equivalent
Cash 5% discount
Quarterly 5% interest
Monthly 7% interest
The program will also compute the total amount to be paid according to the mode of payment.
End Sub
End Sub
End Class
4. Save project as LabEx4. Using If Then ElseIf statement, write a program in VB that will assign a value in
a variable called VClass and km. The program will then identify the rate and additional fee according to
the following:
The program will also compute the total amount to be paid according to the table above. Formula is
rate + (km * additional fee).
Public Class Form1
Dim kilometer, clas As Single
Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
End Sub
End Sub
End Class
5. Save project as LabEx5. Using If Then ElseIf statement, write a program in VB that will assign values in
ten (10) subjects, the program will then compute for the average of the grade and test according to the
following:
End Sub
End Sub
End Sub
End Class
1. Save application as LabSelect1. Using Select Case, write a program in VB that will assign a value in a
noWeek variable and identify the equivalent of the week in number format according to the following:
End Sub
Age Equivalent
60 - Above Senior Citizen
40 59 Adults
20 - 39 Youth
13 - 19 Teenage
0 12 Kids
Select age
Case Is >= 60
MsgBox("Senior Citizen", vbOKOnly, "WindowsApplication")
Case 40 To 59
MsgBox("Adults", vbOKOnly, "WindowsApplication")
Case 20 To 39
MsgBox("Youth", vbOKOnly, "WindowsApplication")
Case 13 To 19
MsgBox("Teenage", vbOKOnly, "WindowsApplication")
Case Is <= 12
MsgBox("Kids", vbOKOnly, "WindowsApplication")
End Select
End Sub
3. Save application as LabSelect3. Using Select Case Statement, write a program in VB that will assign a
value in a grade variable and identify the equivalent of the grade according to the following:
Grade Equivalent
98 100 1.0
95 97 1.25
92 94 1.50
89 91 1.75
86 88 2.0
83 85 2.25
80 82 2.5
77 79 2.75
75 76 3.0
74 below 5.0
End Sub
End Sub
End Class
4. Save application as LabSelect4. Using Select Case statement, write a program in VB that will assign a
value in a meal, drink, and quantity variables and identify the equivalent according to the following:
Drinks Price
S 30
M 35
L 40
Public Class Form1
Dim quantity, meal, drink As String
End Sub
End Select
End Select
Select Case meal
Case "c", "C"
lblorder.Text = "Cheesedog"
Select Case drink
Case "s", "S"
lblamount.Text = (100 * quantity) + (30 * quantity)
lblorder.Text = "Cheesedog and S drinks"
Case "m", "M"
lblamount.Text = (100 * quantity) + (35 * quantity)
lblorder.Text = "Cheesedog and M drinks"
Case "l", "L"
lblamount.Text = (100 * quantity) + (40 * quantity)
lblorder.Text = "Cheesedog and L drinks"
End Select
End Select
Select Case meal
Case "d", "D"
lblorder.Text = "Pizza"
Select Case drink
Case "s", "S"
lblamount.Text = (80 * quantity) + (30 * quantity)
lblorder.Text = "Pizza and S drinks"
Case "m", "M"
lblamount.Text = (80 * quantity) + (35 * quantity)
lblorder.Text = "Pizza and M drinks"
Case "l", "L"
lblamount.Text = (80 * quantity) + (40 * quantity)
lblorder.Text = "Pizza and L drinks"
End Select
End Select
End Sub
End Class
5. Save application as LabSelect5. Using Select Case statement, write a program in VB that will assign a
value in a room type, and identify the equivalent according to the following:
Rate = lblrate.Text
Meal = lblmeal.Text
Code = txtCode.Text
Select Code
Case "1"
lblpayment.Text = "Cash"
Discount = (Rate + Meal) * 0.02
Amount = (Rate + Meal) - Discount
Case "2"
lblpayment.Text = "Credit Cash"
Discount = (Rate + Meal) * 0.05
Amount = (Rate + Meal) + Discount
End Select
lbldiscount.Text = Discount
lbltotal.Text = Amount
End Sub
End Class