how can I calculate the fee ??

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2008
Posts: 7
Reputation: miss.A is an unknown quantity at this point 
Solved Threads: 0
miss.A miss.A is offline Offline
Newbie Poster

how can I calculate the fee ??

 
0
  #1
Apr 22nd, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 291
Reputation: ericstenson is an unknown quantity at this point 
Solved Threads: 29
Team Colleague
ericstenson's Avatar
ericstenson ericstenson is offline Offline
Posting Whiz in Training

Re: how can I calculate the fee ??

 
0
  #2
Apr 23rd, 2008
i would do it like....

  1.  
  2. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  3.  
  4.  
  5. Dim THours As Integer = DateTimePicker2.Value.Hour - DateTimePicker1.Value.Hour
  6. Dim TMinutes As Integer = DateTimePicker2.Value.Minute - DateTimePicker1.Value.Minute
  7.  
  8. Dim TCost As Long
  9.  
  10.  
  11. If TMinutes >= 0 Then
  12.  
  13. TCost = (3 * THours) + (3 * (TMinutes / 60))
  14.  
  15. Else
  16.  
  17. TMinutes = (-1) * TMinutes
  18. TCost = (3 * THours) - (3 * (TMinutes / 60))
  19.  
  20.  
  21. End If
  22.  
  23.  
  24.  
  25. Button1.Text = TCost
--
"Dummy."
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 291
Reputation: ericstenson is an unknown quantity at this point 
Solved Threads: 29
Team Colleague
ericstenson's Avatar
ericstenson ericstenson is offline Offline
Posting Whiz in Training

Re: how can I calculate the fee ??

 
0
  #3
Apr 23rd, 2008
sorry, as DECIMAL, not Long...

and Button1.Text = FormatCurrency(TCost)
--
"Dummy."
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 7
Reputation: miss.A is an unknown quantity at this point 
Solved Threads: 0
miss.A miss.A is offline Offline
Newbie Poster

Re: how can I calculate the fee ??

 
0
  #4
Apr 23rd, 2008
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...
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 7
Reputation: miss.A is an unknown quantity at this point 
Solved Threads: 0
miss.A miss.A is offline Offline
Newbie Poster

Re: how can I calculate the fee ??

 
0
  #5
Apr 23rd, 2008
soo0oory .. No Dim errorflag As Boolean
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC