locked
Comparing time in vb.net RRS feed

  • Question

  • User365103270 posted

    Hi everyone, can i check with you, if i want to compare time... how can i do that... i have the following code

    time_One = Now
    el_Time = time_One - time_Two
    Label1.Text = Now.ToShortTimeString
    If Label1.Text < "06:30:00 PM" Then
    Label1.Text = "-----"
    Else
    Label1.Text = el_Time.ToString
    End If

    I want to compare the current time with "06:30:00 PM"... so if the current time is smaller than "06:30:00 PM", i will do an action... how should i code?

    Please assist me! Thanks!

    Monday, June 9, 2014 2:10 AM

Answers

  • User-1716253493 posted
            If DateTime.Parse(Label1.Text) < DateTime.Parse("06:30:00 PM") Then
                Label1.Text = "-----"
            Else
                Label1.Text = el_Time.ToString
            End If

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 9, 2014 3:19 AM

All replies