VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 在VB中使用枚举变量
发表评论(0)作者:, 平台:, 阅读:12287, 日期:2000-03-12


VB5 引入枚举变量,使用它,我们可以显著地改变应用程序的易读性:

Public Enum TimeOfDay

Morning = 0

Afternoon = 1

Evening = 2

End Enum

Sub Main()

Dim RightNow As TimeOfDay

If Time >= #12:00:00 AM# And Time < #12:00:00 PM# Then

RightNow = Morning

ElseIf Time >= #12:00:00 PM# And Time < #6:00:00 PM# Then

RightNow = Afternoon

ElseIf Time >= #6:00:00 PM# Then

RightNow = Evening

End If

End Sub