programmer friends if I can guide please thank'm trying to make an application of a parking

entry and exit of vehicles

for example a car came and went 12:00 13:00 = 1:00 was an hour would charge $ 500

What if the vehicle was arrived example 12:15 = 12:00 and went was 15 minutes but still charges you $ 500?

another example if the vehicle arrived 12:00 and went was 13:15 = 1:15 entoces every 15 minutes of the hour should depues charged $ 150 every fifteen minutes after the hour

But how do I assign a monetary value to one hour?

Dim fechaini As DateTime
Dim fechafin As DateTime
DateTime.TryParse(TextBox1.Text, fechaini) ' 12:00
DateTime.TryParse(TextBox2.Text, fechafin) '13:00
Dim dif As TimeSpan = fechafin - fechaini
MsgBox(" after " & dif.Hours & ":" & dif.Minutes & " hrs.")

because you want to charge based minutes, you can get totalminutes

try like this

Dim dif As TimeSpan = fechafin - fechaini
Dim tm As Integer = dif.TotalMinutes
Dim firsthour As Double = 500
Dim nextminutes As Double = 0
If tm >= 75 Then '1 hour 15 minutes
Dim m As Integer = (tm / 15) - 4 'one hours = 4 * 15 minutes
nextminutes = m * 150
End If
Dim total As Double = firsthour + nextminutes

Try also Math.Floor / Ceiling to round up/down

Dim m As Integer = Math.Ceiling(tm / 15) - 4 'one hours = 4 * 15 minutes

Dim m As Integer = Math.Floor(tm / 15) - 4 'one hours = 4 * 15 minutes

Programming to simplify, don't look for difficult way
Suwandi - Non Graduate Programmer

check your code but I have a problem
the result put throw eg 12:00 and 14:15 gave me a total of $ 1,250
should be: $ 1,150

Dim fechaini As DateTime
Dim fechafin As DateTime
DateTime.TryParse(TextBox1.Text, fechaini)
DateTime.TryParse(TextBox2.Text, fechafin)
Dim dif As TimeSpan = fechafin - fechaini
Dim tm As Integer = dif.TotalMinutes
Dim firsthour As Double = 500
Dim nextminutes As Double = 0
If tm >= 75 Then '1 hour 15 minutes
Dim m As Integer = (tm / 15) - 4 'one hours = 4 * 15 minutes
nextminutes = m * 150
End If
Dim total As Double = firsthour + nextminutes
TextBox3.Text = total.ToString("")

the result put throw eg 12:00 and 14:15 gave me a total of $ 1,250
should be: $ 1,150

If you mean that more than one hour of the rest of the time are in accordance with the rules of every 150 minutes to pay $15 of the calculation,
oned_gk is right.

But i suspect that you mean that the hour part of an integer is charged at 500 per hour, and if the remaining time less than one hour, it is charged at $150 per 15 minutes. Less than 15 minutes without charging, if the total time less than 60 minutes, it
is charged at $150 per 15 minutes. Less than 15 minutes with charging, isn't it?

Dim fechaini As DateTime
Dim fechafin As DateTime
DateTime.TryParse(TextBox1.Text, fechaini)
DateTime.TryParse(TextBox2.Text, fechafin)
Dim dif As TimeSpan = fechafin - fechaini
Dim tm As Double = dif.TotalMinutes
Dim hourmoney As Double = 0
Dim minutesmoney As Double = 0
If tm >= 60 Then '1 hour 15 minutes
Dim hours As Integer = Int(tm / 60)
Dim m As Integer = Int((tm Mod 60) / 15)
hourmoney = hours * 500
minutesmoney = m * 150
Else
Dim m As Integer = Int(tm / 15)
Dim m1 As Integer = Int(tm Mod 15)
Dim m2 As Integer = 0
If m1 > 0 Then
m2 = 1
End If
minutesmoney = (m + m2) * 150
End If
Dim total As Double = hourmoney + minutesmoney
TextBox3.Text = total.ToString("")

If i misunderstand your problem, please describe your problem in detail.

Member

9 Points

47 Posts

## assign a value to a time vb.net

Feb 05, 2016 12:08 AM|djnilo|LINK

good afternoon

vb.net

mysql

programmer friends if I can guide please thank'm trying to make an application of a parking

entry and exit of vehicles

for example a car came and went 12:00 13:00 = 1:00 was an hour would charge $ 500

What if the vehicle was arrived example 12:15 = 12:00 and went was 15 minutes but still charges you $ 500?

another example if the vehicle arrived 12:00 and went was 13:15 = 1:15 entoces every 15 minutes of the hour should depues charged $ 150 every fifteen minutes after the hour

But how do I assign a monetary value to one hour?

All-Star

52833 Points

15786 Posts

## Re: assign a value to a time vb.net

Feb 05, 2016 12:48 AM|oned_gk|LINK

because you want to charge based minutes, you can get totalminutes

try like this

Try also Math.Floor / Ceiling to round up/down

Suwandi - Non Graduate Programmer

Member

9 Points

47 Posts

## Re: assign a value to a time vb.net

Feb 05, 2016 02:22 AM|djnilo|LINK

thank you very much for answering oned_gk

check your code but I have a problem

the result put throw eg 12:00 and 14:15 gave me a total of $ 1,250

should be: $ 1,150

Star

8460 Points

1445 Posts

## Re: assign a value to a time vb.net

Feb 05, 2016 03:24 AM|Klein Zhang|LINK

Hi djnilo,

If you mean that more than one hour of the rest of the time are in accordance with the rules of every 150 minutes to pay $15 of the calculation, oned_gk is right.

But i suspect that you mean that the hour part of an integer is charged at 500 per hour, and if the remaining time less than one hour, it is charged at $150 per 15 minutes. Less than 15 minutes without charging, if the total time less than 60 minutes, it is charged at $150 per 15 minutes. Less than 15 minutes with charging, isn't it?

If i misunderstand your problem, please describe your problem in detail.

Best Regards,

Klein zhang

Member

9 Points

47 Posts

## Re: assign a value to a time vb.net

Feb 06, 2016 03:42 AM|djnilo|LINK

thank you very much for answering Klein Zhang works perfectly that was