VB.NET - Cheat Sheet to Retrieve Information about Battery Life



Retrieves the percent of battery life left, and warns the user if the percent is below five percent.

'Assembly: System.Windows.Forms.dll
'Namespace: System
'Namespace: Microsoft.VisualBasic
'Namespace: System.Windows.Forms

Dim power As PowerStatus = SystemInformation.PowerStatus
Dim percent As Single = power.BatteryLifePercent
If percent < 0.05 Then
   MsgBox("Percent battery life remaining: " & percent * 100)
End If

Share |

 Cant find the page you are looking for?
 Help us to improve by adding the content that you are looking for.
 Leave a feedback
 We look forward to hear your comments and feedback.