hey guys i need some help on my code here..........
im trying to do some computation about the biling system or a library if the borrwer returns the book on time it will be no charge.......but if hte book is damage then it will charge him trice the ammount of the fineRate also if hes a non member theres an extra charge for it 30% of the FineRate
Dim FineRate As String = My.Settings.FineRate
Dim dmgfee As Double
Dim tot As String
Dim dayslate As String
Dim nm As Double
Dim fac As String
Dim dt1 As Date
Dim dt2 As Date
Dim ef As String
Dim ts As System.TimeSpan
dt1 = DateTimePicker3.Value
dt2 = DateTimePicker4.Value
ts = dt2.Subtract(dt1)
dayslate = ts.Days
If dayslate >= 0 Then
lblDaysLate.Text = dayslate
dayslate = Val(lblDaysLate.Text)
If cboBookStat.Text = "Damage" Then
dmgfee = 0.3 * FineRate
ElseIf cboBookStat.Text = "Un Damage" Then
dmgfee = 0 * FineRate
If lblbtype.Text = "Non Member" Then
nm = 0.3 * FineRate
ElseIf lblbtype.Text = "Member" Then
nm = 0.1 * FineRate
fac = dayslate * FineRate
ef = dmgfee + nm
tot = FineRate * (dayslate + ef)
lblDmgFee.Text = dmgfee
lblTotal.Text = tot
lblTfine.Text = fac
Declare FineRate as double, string won't do. Also change it in My.settings
You calculate daylate, assign it's value to a label and then assign it the value of the label. Can you please explain why you are re-assigning it the same value?
In the description you mention if the book is damaged they the customer has to pay trice the amount of FineRate. Does trice mean 3 times or 30% ?
If the customer is not a member then you add 30%, like you've specified in the description, but if he is a member then you add 10% (?).
You need to reconsider what you are doing in lines 44 and beyond. Fac isn't used -although it should - and you are calculating total like this: tot = FineRate * (dayslate + (damaged_category * FineRate))
Either change it to tot = fac + ef or tot = (FineRate * dayslate) + ef or change dmgfee and nm to hold only the multiplier for the FineRate. Both doesn't make sense.