Question Makeing custom classes

ExEdzy

Active member
Joined
Nov 25, 2010
Messages
37
Programming Experience
3-5
Hey there :)

I love to make my custom classes, for easy programming, so i dont have to go trow tons of code..

so i have created this class:

VB.NET:
Public Class BatteryStatus

    Private Declare Auto Function GetSystemPowerStatus Lib "kernel32.dll" ( _
        ByRef lpSystemPowerStatus As SYSTEM_POWER_STATUS) _
    As Integer

    Public Structure SYSTEM_POWER_STATUS
        Public ACLineStatus As ACLineStatus
        Public BatteryFlag As BatteryFlag
        Public BatteryLifePercent As Byte
        Public Reserved1 As Byte
        Public BatteryLifeTime As Integer
        Public BatteryFullLifeTime As Integer
    End Structure

    ''' <summary>
    ''' Get Battery Flag status
    ''' </summary>
    ''' <remarks></remarks>
    Public Enum BatteryFlag As Byte
        High = 1
        Low = 2
        Critical = 4
        Charging = 8
        NoSystemBattery = 128
        Unknown = 255
    End Enum

    ''' <summary>
    ''' Get Power cable status
    ''' </summary>
    ''' <remarks></remarks>
    Public Enum ACLineStatus As Byte
        Offline = 0
        Online = 1
        Unknown = 255
    End Enum


    Public Shared Function GetStatus() As SYSTEM_POWER_STATUS
        Dim SPS As New SYSTEM_POWER_STATUS
        GetSystemPowerStatus(SPS)
        Return SPS
    End Function


End Class

when i use the code i have to use it like this:

VB.NET:
 If BatteryStatus.BatteryFlag.Charging = BatteryStatus.BatteryFlag.Charging Then

        End If

How do i have to modifie code so i can use it like this:

VB.NET:
 If BatteryStatus.BatteryFlag = BatteryStatus.BatteryFlag.Charging Then

        End If


i hope you understand what i need, and can help me :)
 
Back
Top