How to create vb.net battery status with time?

Asked By 10 points N/A Posted on -
qa-featured

Hello experts,

How to create vb.net battery status with time? I would like to create a system using vb.net 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.

SHARE
Answered By 0 points N/A #181312

How to create vb.net battery status with time?

qa-featured

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