How to: Reuse a Working Component
If a component already exists and is debugged and working, it is to your advantage to use it in your code instead of developing another component with the same functionality. Such a component is usually exposed as a class. To reuse it, you create an object from that class.
The .NET Framework provides many examples of components that are available for use. One such component is theclass in the namespace. TimeZone provides members that allow you to retrieve information about the time zone of the current computer system.
Public Sub examineTimeZone() Dim tz As System.TimeZone = System.TimeZone.CurrentTimeZone Dim s As String = "Current time zone is " s &= CStr(tz.GetUtcOffset(Now).Hours) & " hours and " s &= CStr(tz.GetUtcOffset(Now).Minutes) & " minutes " s &= "different from UTC (coordinated universal time)" s &= vbCrLf & "and is currently " If tz.IsDaylightSavingTime(Now) = False Then s &= "not " s &= "on ""summer time""." MsgBox(s) End Sub
The firstdeclares an object variable of type TimeZone and assigns to it a TimeZone object returned by the property.