Rina
Rina

Reputation: 43

Check if an hour has passed in Vb.net

I tried to make an application where every an hour has passed will add a 100.00 penalty. For example:

10:00am - on time

11:00 - 100.00 late

12:00 - 200.00 late

I'm having a hard time on how will i code that every hour / 100 penalty after 10:00 am. The code below only checks if the time has passed by 11 hours.

Dim time As Date
Dim CurrHour As Integer  
time = DateTime.Now
CurrHour = time.Hour

If CurrHour >= 11 Then
    penalty = "100.00"
End If

lbl_total.Text = penalty

Upvotes: 2

Views: 1369

Answers (1)

pallares
pallares

Reputation: 160

To calculate the penalty you only need this in your code:

Dim _penalty As Integer = (Now.Hour - 10) * 100.0

Upvotes: 1

Related Questions