BatteryStatus Property Example

This example updates a Label control each time there is a change in power status so the application displays current battery status information. To run this example, put a SysInfo control and a Label control on a form. Paste this code into the PowerStatusChanged event of the SysInfo control. Then run the example.

Private Sub SysInfo1_PowerStatusChanged()
   Select Case SysInfo1.BatteryStatus
      Case 1
         Label1.Caption = "Battery OK"
      Case 2
         Label1.Caption = "Battery Low"
      Case 4
         Label1.Caption = "Battery Critical"
      Case 8
         Label1.Caption = "Battery Charging"
      Case 128, 255
         Label1.Caption = "No Battery Status"
   End Select
End Sub