Experimenting with VB code
Wildatheart
Posts: 195
Hello –
I’m trying to compare the Time Of Day Clock (VB8 Express Edition) with variables set from a “Slider” position. Following the code are the 3 Errors I get. Although labels 2 and 10 do work and display the proper time when the If Statement is commented out, I have no clue what it'll take to make the comparison work in the "If Statement".
The area of the errors is between the # and the #. It seems we can't use variables there.
Thanks for your Help.
Dim EventHour As Integer
Dim EventMin As Integer
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label2.Text = System.DateTime.Today.ToLongDateString
Label10.Text = TimeOfDay
If TimeOfDay >= #EventHour:EventMin:00 AM# Then
Label9.Text = "Event passed"
End If
End Sub
Errors
1. Expression Expected
2. Expression is not a Method
3. Syntax Error
I’m trying to compare the Time Of Day Clock (VB8 Express Edition) with variables set from a “Slider” position. Following the code are the 3 Errors I get. Although labels 2 and 10 do work and display the proper time when the If Statement is commented out, I have no clue what it'll take to make the comparison work in the "If Statement".
The area of the errors is between the # and the #. It seems we can't use variables there.
Thanks for your Help.
Dim EventHour As Integer
Dim EventMin As Integer
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label2.Text = System.DateTime.Today.ToLongDateString
Label10.Text = TimeOfDay
If TimeOfDay >= #EventHour:EventMin:00 AM# Then
Label9.Text = "Event passed"
End If
End Sub
Errors
1. Expression Expected
2. Expression is not a Method
3. Syntax Error
Comments
The time is compared as a string value ,·integers EventHour and EventMin·are entered as Military/24 hour time. These variables need to be initialized before the comparison.
The format # time # is hard coding a constant value .
Jeff T.