Enforce Case With Enums
Enumerated constants are great, but they have a quirk that
When you need to determine the last occurrence of a character within a larger string, you typically use a Mid$ or Instr in a loop. VB6
Creating a new project in VB6 (and earlier versions) has always been a pain when you have a large library of modules to add in. You can do it a
Enum DateTimeFormat dtGeneralDate dtLongDate dtMediumDate dtShortDate dtLongTime dtMediumTime dtShortTime dtCustomEnd Enum’ Enhanced VB FormatDateTime functionFunction FormatDateTimeEx(newDate, Optional ByVal dtFormat As DateTimeFormat = _ dtGeneralDate, Optional FirstDayOfWeek As VbDayOfWeek = vbSunday,
‘ Converts a numeric value in seconds to a string’ Example:’ MsgBox SecondsToString(3920) –> 1h.5m.20sFunction SecondsToString(ByVal Seconds As Long) As String SecondsToString = (Seconds 3600) & “h.” & ((Seconds 60)
‘ Converts a time value to a numeric value in seconds’ Example:’ MsgBox TimeToSeconds(TimeSerial(3, 5, 20)) –> 11120Function TimeToSeconds(ByVal newTime As Date) As Long TimeToSeconds = Hour(newTime) * 3600 +
‘ Converts a numeric value in seconds to a time value’ Example:’ MsgBox SecondsToTime(11120) –> 3.5.20 AMFunction SecondsToTime(ByVal Seconds As Long) As Date SecondsToTime = CDate(Seconds / 86400) End Function
‘ Converts a time value to a numeric value in minutes’ Example:’ MsgBox TimeToMinutes(TimeSerial(3, 5, 0)) –> 185Function TimeToMinutes(ByVal newTime As Date) As Long TimeToMinutes = Hour(newTime) * 60 +
Private Declare Function GetSystemPowerStatus Lib “kernel32” _ (lpSystemPowerStatus As SYSTEM_POWER_STATUS) As LongPrivate Type SYSTEM_POWER_STATUS ACLineStatus As Byte BatteryFlag As Byte BatteryLifePercent As Byte Reserved1 As Byte BatteryLifeTime As Long BatteryFullLifeTime