Andrew Henz Andrew Henz - 11 months ago 87 Question battery life percentage

I tried many methods trying to make a small programs which shows the battery percentage (the value is displayed on a progressbar).Can anyone help me?

Dim power As SystemInformation.PowerStatus = SystemInformation.PowerStatus
Dim percent As Single = power.BatteryLifePercent    

' Display the ProgressBar control.
    pBar1.Visible = true;

' Set min and max
    pBar1.Minimum = 0
    pBar1.Maximum = 100

' Set the current value 
    pBar1.Value = percent * 100

Then you just need to refresh with a timer or something else.