A book stall gives discount on the books as per following conditions:
No. of books purchased Discount
a. <=5 Nil 0
b. >5 and <=10 10%
c. >10 and <=15 12%
d. >15 20%
Create a form as follows to calculate the discount.
Form Design :
Coding:
Dim u_price As Single
Dim n As Single
Dim t_price As Single
Dim discount As Single
Sub pro()
u_price = Val(Text1.Text)
n = Val(Text2.Text)
t_price = n * u_price
Text3.Text = t_price
If n <= 5 Then
discount = 0
ElseIf n > 5 And n <= 10 Then
discount = 0.1 * t_price
ElseIf n > 10 And n <= 15 Then
discount = 0.12 * t_price
Else
discount = 0.2 * t_price
End If
End Sub
Private Sub Command1_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Text3_GotFocus()
pro
u_price = Val(Text1.Text)
t_price = n * u_price
Text3.Text = t_price
End Sub
Private Sub Text4_GotFocus()
pro
u_price = Val(Text1.Text)
t_price = n * u_price
Text4.Text = discount
End Sub
Private Sub Text5_GotFocus()
pro
u_price = Val(Text1.Text)
t_price = n * u_price
Text5.Text = t_price - discount
End Sub
Output :
No comments:
Post a Comment
This Blog helps you to learn basics to high level programming coding and practicals.
conceptual understanding