How to create battery status with time?

Asked By 10 points N/A Posted on -

Hello experts,

How to create battery status with time? I would like to create a system using regarding battery status with time that will also enable the user to detect the mobile phone battery status. Whether if it is still active or already defective. This is very important for me, any suggestions and coding technique answers will do.

Thank you.

Answered By 10 points N/A #181312

How to create battery status with time?


Hi Jayden,

In Visual Studio, we have a build in class for getting battery status which is “PowerStatus” and we can get the system’s power status by the following code:
  1. Dim psSystemBattery As PowerStatus = SystemInformation.PowerStatus
  2. We can get the remaining battery from “BatteryLifePercent“property of PowerStatus class. There is one Enum “PowerLineStatus” which can be useful for you like “PowerLineStatus.Online”.
  3. If psSystemBattery.PowerLineStatus = PowerLineStatus.Online Then ’’Means battery is charging".
  4. ElseIf psSystemBattery.PowerLineStatus = PowerLineStatus.Offline Then ’’Means battery is not charging".
I hope this information will helps you. Thank you

Login/Register to Answer

Related Questions