Sunday, December 9, 2012

Program for calculating the bill using select case in visual basic


Dim unit As Integer
Dim amt As Double
Private Sub CmdCalculate_Click()
unit = Val(Txtnum1.Text)
Select Case unit
Case 0 To 150
amt = CDbl((250 + 0.6) * unit)
Case 151 To 300
amt = CDbl((250 + 100 + 1#) * (unit - 150))
Case 301 To 450
amt = CDbl((250 + 200 + 1.25) * (unit - 300))
Case Else
amt = CDbl((250 + 300 + 1.75) * (unit - 450))
End Select
LblAmt.Caption = amt
End Sub
Private Sub CmdExit_Click()
End
End Sub



 Output
Note:- Please set some property of your control like caption or id corresponding to your control