Seems OK. Some suggestions:
Code:
Public Class Form1
Inherits System.Windows.Forms.Form
' Enum...
Public Enum dayaction As Integer
Asleep = 0
gettingreadyforwork = 1
travellingtowork = 2
atwork = 3
atlunch = 4
travellingfromwork = 5
relaxingwithfriends = 6
gettingreadyforbed = 7
End Enum
' Members
Public currentstate As dayaction
' Hour property
Public Property hour() As Integer
Get
Return trkhour.Value
End Get
Set(ByVal value As Integer)
trkhour.Value = value ' Set the hour
' You already have an integer named value. Why
' transfer it to another integer?
' Dim hour As Integer = value ' Determine the state
Select Case value ' Since hour is an integer, . . .
Case 6 ' 6 is the only int >= 6 and < 7
currentstate = dayaction.travellingtowork
Case 7 ' 7 is the only int >= 7 and < 8
currentstate = dayaction.travellingtowork
Case 8, 9, 10, 11, 12 ' This is how incluse Between is done in a Select Case.
currentstate = dayaction.atwork
Case 13
currentstate = dayaction.atlunch
Case 14, 15, 16
currentstate = dayaction.atwork
Case 17
currentstate = dayaction.travellingfromwork
Case 18, 19, 20, 21
currentstate = dayaction.relaxingwithfriends
Case 22
currentstate = dayaction.gettingreadyforbed
Case Else
currentstate = dayaction.Asleep
End Select
' Set the text
' Update the display
txtstate.Text = "At " & value & ":00, Len is " & currentstate.ToString()
End Set
End Property
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Set the hour to the current hour
Me.hour = Date.Now.Hour
End Sub
Private Sub trkhour_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trkhour.Scroll
' Update the hour
Me.hour = trkhour.Value
End Sub
End Class