Move to class ??

Charlez

Member
Joined
Oct 10, 2009
Messages
5
Programming Experience
Beginner
Is it possible to clean up the code below so only the function remains.
What i mean is move the if statement into the class.
It's possible when returning a array of booleans, but i prefer not to do that.


VB.NET:
Dim objDrukknop As Drukknop
        objDrukknop = New Drukknop
dim StatusDigInput1 as boolean
Dim Last_StatusCard1DigInput1_State as boolean


        'Digital Input 1 Card 1 ===> Digital Output 1 Card 1
        If Last_StatusCard1DigInput1_State <> StatusDigInput1 Then
            StatusDigOutput1 = objDrukknop.fnDigOut(StatusDigInput1, StatusDigOutput1, Card1, 1)
            'save state of StatusCard1DigInput1 into Last_StatusCard1DigInput1_State
            Last_StatusCard1DigInput1_State = StatusDigInput1
        End If



VB.NET:
Public Class Drukknop
    Public Function fnDigOut(ByRef StatusDigInput As Boolean, ByRef StatusDigOutput As Boolean, _
                             ByRef Card As Integer, ByRef CardOutput As Integer) As Boolean
        'StatusCard1DigInput1 has changed
        If StatusDigInput = True Then
            'process on rising edge of StatusCard1DigInput1
            If StatusDigOutput = False Then
                Form1.SetDigitalChannel(Card, CardOutput)
                StatusDigOutput = True
            Else
                StatusDigOutput = False
                Form1.ClearDigitalChannel(Card, CardOutput)
            End If
        End If
        Return StatusDigOutput
    End Function
End Class
 
Back
Top