0

Hi, i have three textboxs, system time is in texbox1 , "09:00:00" is in textbox2 and i want to two times Comparison in vb.net, textbox3=textbox2 - textbox2, is any solution?

Edited by snip: n/a

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by sknake
0

You can compare the string value if you're trying to determine if they are identical:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    If (String.Compare(TextBox1.Text, TextBox2.Text, True) = 0) Then
      'Same value
    End If
  End Sub

To do it like you're supposed to you could load the data in to a DateTime :

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    Dim dt1 As DateTime, dt2 As DateTime
    If Not (DateTime.TryParse(TextBox1.Text, dt1)) Then
      MessageBox.Show("Invalid datetime in textedit1")
      Return
    End If
    If Not (DateTime.TryParse(TextBox2.Text, dt2)) Then
      MessageBox.Show("Invalid datetime in textedit1")
      Return
    End If
    If (dt1 = dt2) Then
      MessageBox.Show("Times are equal")
      'Times are equal
    End If
  End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.