| | |
how can I calculate the fee ??
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 7
Reputation:
Solved Threads: 0
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
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
i would do it like....
VB.NET Syntax (Toggle Plain Text)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim THours As Integer = DateTimePicker2.Value.Hour - DateTimePicker1.Value.Hour Dim TMinutes As Integer = DateTimePicker2.Value.Minute - DateTimePicker1.Value.Minute Dim TCost As Long If TMinutes >= 0 Then TCost = (3 * THours) + (3 * (TMinutes / 60)) Else TMinutes = (-1) * TMinutes TCost = (3 * THours) - (3 * (TMinutes / 60)) End If Button1.Text = TCost
--
"Dummy."
"Dummy."
•
•
Join Date: Mar 2008
Posts: 7
Reputation:
Solved Threads: 0
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...
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...
![]() |
Similar Threads
- Almost Got It, I think (C++)
- PayPal? - vs. other online escrow services (eCommerce)
- car park C programming (C)
- C Programming-Adding overdraft fee (C)
- I need to write a C++ Code from the following info. HOW DO I... (C++)
- parking fee (C++)
- Can't see the program execute (C++)
- water program using subprograms (Computer Science)
- Im lost in my program, plesae please help (C)
Other Threads in the VB.NET Forum
- Previous Thread: MDI Parent Form Layout Problem
- Next Thread: Go to specific control
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access account arithmetic array assignment basic binary bing button buttons center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist excel file-dialog firewall folder ftp google hardcopy image images insert isnumericfuntioncall listview login math memory mobile ms navigate net networking opacity output passingparameters peertopeervideostreaming picturebox picturebox1 port print problemwithinstallation project reports" save savedialog searchbox serial soap sorting string table tcp temp text textbox timer toolbox trim update updown upload useraccounts usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio web wpf





