vb.net数组结构——枚举类型

2025-05-04 16:55:35

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

vb.net数组结构——枚举类型

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

vb.net数组结构——枚举类型

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

vb.net数组结构——枚举类型

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

vb.net数组结构——枚举类型

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

vb.net数组结构——枚举类型
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢