Я работаю над кодом, который скрывает и показывает время в Access VBA.
Из моего тестирования, кажется, пропускается If
и продолжается Else
.
Мне требуется Visible1
для отображения в период с 07:30:00 до 23:59:59, в то время как Visible2
для отображения в период с 00:00:00 до 07:30:00. В любой момент времени должно появиться Visible1
или Visible2
.
Private Sub Form_Current()
Dim Visible1 As Boolean
Dim Visible2 As Boolean
Dim currentTime As String
Dim currentTimestring As String
currentTime = Time()
currentTimestring = Format(currentTime, "hh:mm:tt")
If currentTimestring >= TimeValue("07:30:00") And currentTimestring < TimeValue("00:00:00") Then
Visible2 = True
Visible1 = False
Else
Visible1 = True
Visible2 = False
End If
Me.Label22.Visible = Visible1
Me.Label11.Visible = Visible1
Me.Text10.Visible = Visible1
Me.Label13.Visible = Visible1
Me.Text12.Visible = Visible1
Me.Label23.Visible = Visible2
Me.Label16.Visible = Visible2
Me.Label18.Visible = Visible2
Me.Text15.Visible = Visible2
Me.Text17.Visible = Visible2
End Sub