【问题标题】:Substracting End and Start times to find difference in minutes减去结束时间和开始时间以找出以分钟为单位的差异
【发布时间】:2016-03-09 06:08:27
【问题描述】:

所以我需要查看两次之间是否至少有 10 分钟才能使我的操作员为真或不正确,以便它知道是否发出警报 下面是 VB.net 中的代码

        Dim LessThanTen As Double

    Dim CheckTimeBegin As DateTime = Convert.ToDateTime(txttimebegin.Text)
    Dim CheckTimeEnd As DateTime = Convert.ToDateTime(txttimeend.Text)



    Dim Duration As TimeSpan = CheckTimeEnd - CheckTimeBegin

    If Duration.TotalMinutes < 10 Then
        LessThanTen = True
    Else
        LessThanTen = False
    End If

【问题讨论】:

  • 有什么问题?
  • 我用 ParseExact 修复了我的道歉

标签: vb.net time


【解决方案1】:

修好了

        Dim LessThanTen As Double

    Dim Startt = DateTime.ParseExact(txttimebegin.Text, "h:mm:tt", Nothing)
    Dim Endt = DateTime.ParseExact(txttimeend.Text, "h:mm:tt", Nothing)

    Dim Duration As TimeSpan = Startt - Endt

    If Duration.TotalMinutes < 10 Then
        LessThanTen = True
    Else
        LessThanTen = False
    End If

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-31
    • 1970-01-01
    • 2022-12-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多