VB.net电池寿命百分比

时间:2016-05-13 12:38:54

标签: vb.net percentage battery

我尝试了很多方法试图制作一个显示电池百分比的小程序(值显示在进度条上)。任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

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

然后你只需要用计时器或其他东西刷新。