Visual Basic: SysInfo Control
BatteryLifePercent Property Example
This example uses a ProgressBar control on a form to show the status of the system battery's remaining power. To run this example, put a SysInfo control, a ProgressBar control and a Timer control on a form. Paste this code into the Timer event of the Timer control. Set the Interval property of the Timer control to 5000, then run the example.
Private Sub Timer1_Timer()
If SysInfo1.BatteryLifePercent <> 255 Then
ProgressBar1.Value = SysInfo1.BatteryLifePercent
ProgressBar1.Enabled = True
Else
ProgressBar1.Value = 0
ProgressBar1.Enabled = False
End If
End Sub