Commentçamarche.net
CodeS-SourceS
Rechercher un code, un tuto, une réponse

K8055 commande des sorties

1/5 (35 avis)

Vue 6 421 fois - Téléchargée 446 fois

Description

c'est ma premiere source un peut d'indulgence (et en plus je l'ai pas commenté)
PAT9SAB voulais commandé c sorti en un clic
donc voila
avec une icone dans la barre des tache et un menu contextuel

Source / Exemple :


Public Class Form1

    Private Declare Function OpenDevice Lib "k8055d.dll" (ByVal CardAddress As Long) As Long
    Private Declare Sub CloseDevice Lib "k8055d.dll" ()
    Private Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal Data As Long)
    Private Declare Sub ClearDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long)
    Private Declare Sub ClearAllDigital Lib "k8055d.dll" ()
    Private Declare Sub SetDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long)
    Private Declare Sub SetAllDigital Lib "k8055d.dll" ()
    Private Declare Function ReadDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long) As Boolean
    Private Declare Function ReadAllDigital Lib "k8055d.dll" () As Long
    Private Declare Function ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long) As Long
    Private Declare Sub ReadAllAnalog Lib "k8055d.dll" (ByVal Data1 As Long, ByVal Data2 As Long)
    Private Declare Sub OutputAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long, ByVal Data As Long)
    Private Declare Sub OutputAllAnalog Lib "k8055d.dll" (ByVal Data1 As Long, ByVal Data2 As Long)
    Private Declare Sub ClearAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long)
    Private Declare Sub SetAllAnalog Lib "k8055d.dll" ()
    Private Declare Sub ClearAllAnalog Lib "k8055d.dll" ()
    Private Declare Sub SetAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long)

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        NotifyIcon1.Visible = True

        Dim h As Long

        Dim CardAddress As Long
        CardAddress = 0

        h = OpenDevice(CardAddress)
Select h
            Case (0)
                Label2.Text = "carte connecté"
            Case (-1)
                Label2.Text = "Impossible de connecter la carte"
        End Select

    End Sub
    Private Sub sorti1()
        If Button1.Text = "Off" Then
            SortieN1ToolStripMenuItem.Checked = True
            Button1.Text = "On"
            SetDigitalChannel(1)
            CheckBox1.Checked = True

        Else : Button1.Text = "On"
            SortieN1ToolStripMenuItem.Checked = False
            Button1.Text = "Off"
            ClearDigitalChannel(1)
            CheckBox1.Checked = False
        End If

    End Sub

    Private Sub sorti2()
        If Button2.Text = "Off" Then
            SortieN2ToolStripMenuItem.Checked = True
            Button2.Text = "On"
            SetDigitalChannel(2)
            CheckBox2.Checked = True

        Else : Button2.Text = "On"
            SortieN2ToolStripMenuItem.Checked = False
            Button2.Text = "Off"
            ClearDigitalChannel(2)
            CheckBox2.Checked = False
        End If

    End Sub
    Private Sub sorti3()
        If Button3.Text = "Off" Then
            SortieN3ToolStripMenuItem.Checked = True
            Button3.Text = "On"
            SetDigitalChannel(3)
            CheckBox3.Checked = True

        Else : Button3.Text = "On"
            SortieN3ToolStripMenuItem.Checked = False
            Button3.Text = "Off"
            ClearDigitalChannel(3)
            CheckBox3.Checked = False
        End If

    End Sub
    Private Sub sorti4()
        If Button4.Text = "Off" Then
            SortieN4ToolStripMenuItem.Checked = True
            Button4.Text = "On"
            SetDigitalChannel(4)
            CheckBox4.Checked = True

        Else : Button4.Text = "On"
            SortieN4ToolStripMenuItem.Checked = False
            Button4.Text = "Off"
            ClearDigitalChannel(4)
            CheckBox4.Checked = False
        End If

    End Sub
    Private Sub sorti5()
        If Button5.Text = "Off" Then
            SortieN5ToolStripMenuItem.Checked = True
            Button5.Text = "On"
            SetDigitalChannel(5)
            CheckBox5.Checked = True

        Else : Button5.Text = "On"
            SortieN5ToolStripMenuItem.Checked = False
            Button5.Text = "Off"
            ClearDigitalChannel(5)
            CheckBox5.Checked = False
        End If

    End Sub
    Private Sub sorti6()
        If Button6.Text = "Off" Then
            SortieN6ToolStripMenuItem.Checked = True
            Button6.Text = "On"
            SetDigitalChannel(6)
            CheckBox6.Checked = True

        Else : Button6.Text = "On"
            SortieN6ToolStripMenuItem.Checked = False
            Button6.Text = "Off"
            ClearDigitalChannel(6)
            CheckBox6.Checked = False
        End If

    End Sub
    Private Sub sorti7()
        If Button7.Text = "Off" Then
            SortieN7ToolStripMenuItem.Checked = True
            Button7.Text = "On"
            SetDigitalChannel(7)
            CheckBox7.Checked = True

        Else : Button7.Text = "On"
            SortieN7ToolStripMenuItem.Checked = False
            Button7.Text = "Off"
            ClearDigitalChannel(7)
            CheckBox7.Checked = False
        End If

    End Sub
    Private Sub sorti8()
        If Button8.Text = "Off" Then
            SortieN8ToolStripMenuItem.Checked = True
            Button8.Text = "On"
            SetDigitalChannel(8)
            CheckBox8.Checked = True

        Else : Button8.Text = "On"
            SortieN8ToolStripMenuItem.Checked = False
            Button8.Text = "Off"
            ClearDigitalChannel(8)
            CheckBox8.Checked = False
        End If

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        sorti1()

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        sorti2()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        sorti3()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        sorti4()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        sorti5()
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        sorti6()
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        sorti7()
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        sorti8()
    End Sub

    Private Sub SortieN1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortieN1ToolStripMenuItem.Click
        sorti1()
    End Sub

    Private Sub SortieN2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortieN2ToolStripMenuItem.Click
        sorti2()
    End Sub

    Private Sub SortieN3ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortieN3ToolStripMenuItem.Click
        sorti3()
    End Sub

    Private Sub SortieN4ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortieN4ToolStripMenuItem.Click
        sorti4()
    End Sub

    Private Sub SortieN5ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortieN5ToolStripMenuItem.Click
        sorti5()
    End Sub

    Private Sub SortieN6ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortieN6ToolStripMenuItem.Click
        sorti6()
    End Sub

    Private Sub SortieN7ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortieN7ToolStripMenuItem.Click
        sorti7()
    End Sub

    Private Sub SortieN8ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortieN8ToolStripMenuItem.Click
        sorti8()
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        Dim h As Long

        Dim CardAddress As Long
        CardAddress = 0

        h = OpenDevice(CardAddress)
        Select Case h
            Case (0)
                Label2.Text = "carte connecté"
            Case (-1)
                Label2.Text = "Impossible de connecter la carte"
        End Select

    End Sub

End Class

Conclusion :


pas essayer j'avais pas de carte sous la main

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.