![]() |
| ||
| how can I calculate the fee ?? I have to create an application that calculate parking garage fee by using VB.Net and use timepicker for time in and time out. For each hour it cost 3$ and it calculate minutes as 1\60. I start coding but I face problem with how can I calculate the fee and the car can’t stay overnight.. it should leave in same day… This is my code… Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim HourlyRate As Decimal Dim TimeIn As Double Dim TimeOut As Double Dim calculat As Double HourlyRate = 3 TimeIn = DateTimePicker1.Text TimeOut = DateTimePicker2.Text calculat = Fee(DateTimePicker1.Text, DateTimePicker2.Text, HourlyRate) Label1.Text = calculat.ToString + "$" End Sub Function Fee(ByVal TimeIn As Integer, ByVal TimeOut As Integer, _ ByVal HourlyRate As Decimal) As Decimal Dim calculat As Double calculat = (TimeIn - TimeOut) * HourlyRate Return calculat End Function End Class |
| ||
| Re: how can I calculate the fee ?? i would do it like....
|
| ||
| Re: how can I calculate the fee ?? sorry, as DECIMAL, not Long... and Button1.Text = FormatCurrency(TCost) |
| ||
| Re: how can I calculate the fee ?? mmmm... i do it in this way Public Class Form1 Dim TimeInHou As Integer Dim TimeOutHou As Integer Dim TimeInMun As Integer Dim TimeOutMun As Integer Dim errorflag As Boolean Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TimeInHou = DateTimePicker1.Value.Hour TimeOutHou = DateTimePicker2.Value.Hour TimeInMun = DateTimePicker1.Value.Minute TimeOutMun = DateTimePicker2.Value.Minute Dim calculat As Double If TimeOutHou > TimeInHou Then calculat = ((DateTimePicker2.Value.Hour - DateTimePicker1.Value.Hour) + ((DateTimePicker2.Value.Minute - DateTimePicker1.Value.Minute) \ 60)) * 3 Label1.Text = calculat.ToString + "$" End If End Sub Function Fee(ByVal TimeInHou As Integer, ByVal TimeOutHou As Integer, ByVal TimeInMun As Integer, ByVal TimeOutMun As Integer) As Integer Dim calculat As Double calculat = ((TimeOutHou - TimeInHou) + ((TimeOutMun - TimeInMun) \ 60)) * 3 End Function End Class it works ... but i don't know how to validate this so the car should leave in same day and no park at overnight... |
| ||
| Re: how can I calculate the fee ?? soo0oory .. No Dim errorflag As Boolean |
| All times are GMT -4. The time now is 6:35 pm. |
Forum system based on vBulletin Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
©2003 - 2010 DaniWeb® LLC