我怎样才能一次又一次地发送中午 12 点 vb6

How can i send time after time 12am vb6

我已经对它进行了编码,但它并没有执行我所编码的操作。这是我的代码:

Private Sub timer_Timer()
    dateoutput.Caption = Format(Now, "General date")
        If theTime >= #12:00:00 AM# And theTime <= #11:59:59 AM# Then
            welcome.Caption = "Good Morning"
        ElseIf theTime >= #11:59:59 AM# And theTime <= #6:00:00 PM# Then
            welcome.Caption = "Good Evening"
        ElseIf theTime >= #6:00:00 PM# And theTime <= #11:59:59 PM# Then
            welcome.Caption = "Good Night"
        End If
End Sub

你在 12:00:00 AM => PM

有点错误
Private Sub timer_Timer()
    dateoutput.Caption = Format(Now, "General date")
        If theTime >= #12:00:00 PM# And theTime <= #11:59:59 AM# Then
            welcome.Caption = "Good Morning"
        ElseIf theTime >= #11:59:59 AM# And theTime <= #6:00:00 PM# Then
            welcome.Caption = "Good Evening"
        ElseIf theTime >= #6:00:00 PM# And theTime <= #11:59:59 PM# Then
            welcome.Caption = "Good Night"
        End If
End Sub

我认为问题在于您将具有日期组件的内容与不具有日期组件的内容进行比较,因此您永远无法按照您想要的方式工作。

这个更好:

Private Sub Timer_Timer()
    Dim theTime As String
    theTime = TimeValue(Now)

    dateOutput.Caption = Format(Now, "General date")

    If theTime >= #12:00:00 AM# And theTime < #12:00:00 PM# Then
        welcome.Caption = "Good Morning"
    ElseIf theTime >= #12:00:00 PM# And theTime < #6:00:00 PM# Then
        welcome.Caption = "Good Evening"
    ElseIf theTime >= #6:00:00 PM# And theTime <= #11:59:59 PM# Then
        welcome.Caption = "Good Night"
    End If
End Sub

另请注意,我稍微更改了用于检查范围的值。 编辑它不喜欢检查“<#12:00:00 AM#”所以它需要是“<#11:59:59 PM#”