vb.net数组结构——枚举类型
vb.net中的枚举数据类型
工具/原料
visual studio 2015
使用枚举类型
1、Record a DayAction of one of the following possible values:AsleepGetting ready for workTraveling to workAt workAt lunchTraveling from workRelaxing with friendsGetting ready for bed

3、'Declare variablePrivate CurrentState As DayActionAdd the followi荏鱿胫协ng code below the variable you just added:'Hour propertyPrivate Property Hour() As Integer Get 'Return the current hour displayed Return dtpHour.Value.Hour End Get Set(value As Integer) 'Set the date using the hour passed to this property dtpHour.Value = New Date(Now.Year, Now.Month, Now.Day, value, 0, 0) 'Set the display text lblState.Text = "At " & value & ":00, Richard is " End SetEnd Property

4、Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load 'Set the Hour property to the current hour Me.Hour = Now.HourEnd Sub

6、执行结果入戏图所示:

2、'Set the display text lblState.Text = "At " & value & ":00, Richard is " & CurrentState.ToString()End Set
