"Lucky me," writes Joe from the Submit-To-WTF Visual Studio Add-In, "I just inherited a home-grown system information application."

"Judging from the code the previous programmer wrote, this is sadly one of the better pieces."

Public ReadOnly Property BatteryPercent()
    ' This code will retrieve the BatteryLifePercent property and convert it to a percent.
    Get
        If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
            Return "100%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
            Return "99%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
            Return "98%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
            Return "97%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.96" Then
            Return "96%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.95" Then
            Return "95%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.94" Then
            Return "94%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.93" Then
            Return "93%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.92" Then
            Return "92%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.91" Then
            Return "91%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.9" Then
            Return "90%"
        '...
        'snip
        '...
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.2" Then
            Return "20%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.19" Then
            Return "19%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.18" Then
            Return "18%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.17" Then
            Return "17%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.16" Then
            Return "16%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.15" Then
            Return "15%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.14" Then
            Return "14%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.13" Then
            Return "13%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.12" Then
            Return "12%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.11" Then
            Return "11%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.1" Then
            Return "10%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.09" Then
            Return "9%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.08" Then
            Return "8%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.07" Then
            Return "7%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.06" Then
            Return "6%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.05" Then
            Return "5%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.04" Then
            Return "4%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.03" Then
            Return "3%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.02" Then
            Return "2%"
        ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.01" Then
            Return "1%"
        Else
            Return "NA"
        End If
    End Get
End Property
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!