Index

Résolu
Signaler
Messages postés
44
Date d'inscription
dimanche 21 novembre 2004
Statut
Membre
Dernière intervention
9 juin 2007
-
Messages postés
34
Date d'inscription
lundi 6 janvier 2003
Statut
Membre
Dernière intervention
29 mars 2008
-
Bonjour voila j'ai un petit problème vb
j'ai surligné mon code la ou j'ai mon beug
j'utilise une carte k8055

qui commanderai un assenceur ...
Les commande commandes les étages

et les check2 devraient définir indexé 0 a 4
que si ils ne sont pas tous coché les command index 1 a 8

comment dire que les check2 si ils ne sont pas tous coché
ne montre pas les commandes

VERSION 5.00
Begin VB.Form Form3
Caption = "Form1"
ClientHeight = 5820
ClientLeft = 60
ClientTop = 390
ClientWidth = 8340
LinkTopic = "Form1"
ScaleHeight = 5820
ScaleWidth = 8340
StartUpPosition = 3 'Windows Default
Begin VB.Timer Timer1
Left = 3360
Top = 2040
End
Begin VB.Frame Frame6
Caption = "Inputs"
Height = 735
Left = 3840
TabIndex = 19
Top = 0
Width = 2355
Begin VB.CheckBox Check2
Caption = "1"
Height = 255
Index = 0
Left = 120
TabIndex = 24
Top = 300
Width = 495
End
Begin VB.CheckBox Check2
Caption = "2"
Height = 255
Index = 1
Left = 540
TabIndex = 23
Top = 300
Width = 495
End
Begin VB.CheckBox Check2
Caption = "3"
Height = 255
Index = 2
Left = 960
TabIndex = 22
Top = 300
Width = 495
End
Begin VB.CheckBox Check2
Caption = "4"
Height = 255
Index = 3
Left = 1380
TabIndex = 21
Top = 300
Width = 495
End
Begin VB.CheckBox Check2
Caption = "5"
Height = 255
Index = 4
Left = 1860
TabIndex = 20
Top = 300
Width = 435
End
End
Begin VB.CommandButton Command
Caption = "Command(8)"
Height = 735
Index = 8
Left = 7200
TabIndex = 18
Top = 5040
Width = 1095
End
Begin VB.CommandButton Command
Caption = "Command(7)"
Height = 735
Index = 7
Left = 7200
TabIndex = 17
Top = 4320
Width = 1095
End
Begin VB.CommandButton Command
Caption = "Command(6)"
Height = 735
Index = 6
Left = 7200
TabIndex = 16
Top = 3600
Width = 1095
End
Begin VB.CommandButton Command
Caption = "Command(5)"
Height = 735
Index = 5
Left = 7200
TabIndex = 15
Top = 2880
Width = 1095
End
Begin VB.CommandButton Command
Caption = "Command(4)"
Height = 735
Index = 4
Left = 7200
TabIndex = 14
Top = 2160
Width = 1095
End
Begin VB.CommandButton Command
Caption = "Command(3)"
Height = 735
Index = 3
Left = 7200
TabIndex = 13
Top = 1440
Width = 1095
End
Begin VB.CommandButton Command
Caption = "Command(2)"
Height = 735
Index = 2
Left = 7200
TabIndex = 12
Top = 720
Width = 1095
End
Begin VB.CommandButton Command
Caption = "Command(1)"
Height = 735
Index = 1
Left = 7200
TabIndex = 11
Top = 0
Width = 1095
End
Begin VB.Frame Frame7
Caption = "Outputs"
Height = 735
Left = 0
TabIndex = 2
Top = 0
Width = 3555
Begin VB.CheckBox Check3
Caption = "1"
Height = 255
Index = 0
Left = 120
TabIndex = 10
Top = 300
Width = 375
End
Begin VB.CheckBox Check3
Caption = "2"
Height = 255
Index = 1
Left = 540
TabIndex = 9
Top = 300
Width = 375
End
Begin VB.CheckBox Check3
Caption = "3"
Height = 255
Index = 2
Left = 960
TabIndex = 8
Top = 300
Width = 375
End
Begin VB.CheckBox Check3
Caption = "4"
Height = 255
Index = 3
Left = 1380
TabIndex = 7
Top = 300
Width = 375
End
Begin VB.CheckBox Check3
Caption = "5"
Height = 255
Index = 4
Left = 1800
TabIndex = 6
Top = 300
Width = 375
End
Begin VB.CheckBox Check3
Caption = "6"
Height = 255
Index = 5
Left = 2220
TabIndex = 5
Top = 300
Width = 375
End
Begin VB.CheckBox Check3
Caption = "7"
Height = 255
Index = 6
Left = 2640
TabIndex = 4
Top = 300
Width = 375
End
Begin VB.CheckBox Check3
Caption = "8"
Height = 255
Index = 7
Left = 3060
TabIndex = 3
Top = 300
Width = 375
End
End
Begin VB.CommandButton connect
Caption = "test connect"
Height = 615
Left = 0
TabIndex = 0
Top = 960
Width = 1215
End
Begin VB.Shape Shape
Height = 735
Index = 8
Left = 6480
Top = 5040
Width = 735
End
Begin VB.Shape Shape
Height = 735
Index = 7
Left = 6480
Top = 4320
Width = 735
End
Begin VB.Shape Shape
Height = 735
Index = 6
Left = 6480
Top = 3600
Width = 735
End
Begin VB.Shape Shape
Height = 735
Index = 5
Left = 6480
Top = 2880
Width = 735
End
Begin VB.Shape Shape
Height = 735
Index = 4
Left = 6480
Top = 2160
Width = 735
End
Begin VB.Shape Shape
Height = 735
Index = 3
Left = 6480
Top = 1440
Width = 735
End
Begin VB.Shape Shape
Height = 735
Index = 2
Left = 6480
Top = 720
Width = 735
End
Begin VB.Shape Shape
Height = 735
Index = 1
Left = 6480
Top = 0
Width = 735
End
Begin VB.Label Label1
Caption = "---"
Height = 255
Left = 0
TabIndex = 1
Top = 1800
Width = 1935
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'
Dim DoNothing As Boolean '<- je vois pas à quoi il sert, il ne change jamais
'Dim n As Integer '<- pas la peine de le déclarer 2 fois
'
Private Declare Function OpenDevice Lib "k8055d.dll" (ByVal cardaddress As Long) As Long
Private Declare Sub CloseDevice Lib "k8055d.dll" ()
Private Declare Function ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long) As Long
Private Declare Sub ReadAllAnalog Lib "k8055d.dll" (Data1 As Long, 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 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 ReadCounter Lib "k8055d.dll" (ByVal CounterNr As Long) As Long
Private Declare Sub ResetCounter Lib "k8055d.dll" (ByVal CounterNr As Long)
Private Declare Sub SetCounterDebounceTime Lib "k8055d.dll" (ByVal CounterNr As Long, ByVal DebounceTime As Long)
'
'
Private Sub Check3_Click(index As Integer)
Dim i As Long
Dim n As Long
n = 0
For i = 0 To 7
n = n + Check3(i).Value * (2 ^ i) '<-- pas très propre d'utiliser un booléen...
Next
If Not DoNothing Then WriteAllDigital n
End Sub
'
'
Private Sub Command_Click(index As Integer) '<- commencent à 1
ClearAllDigital
Call carte(index)
'If Command(Index).Value Then ... '<-- pourquoi tester la valeur du bouton?!
Call ChangeAscenseur(index)
End Sub



'
'
Private Sub connect_Click()
Dim cardaddress As Long
Dim h As Long
cardaddress = 0
h = OpenDevice(cardaddress)

Select Case h
Case 0, 1, 2, 3
Label1.Caption = "card" + Str(h) + " connected"

Case -1
Label1.Caption = "Card " + Str(cardaddress) + " not found"
End Select
End Sub
Private Sub Form_Load()
Dim cardaddress As Long
Dim h As Long
cardaddress = 0
h = OpenDevice(cardaddress)

Select Case h
Case 0, 1, 2, 3
Label1.Caption = "card" + Str(h) + " connected"

Case -1
Label1.Caption = "Card " + Str(cardaddress) + " not found"
End Select
End Sub



'
'
Private Sub test_Click()
Form2.Show
Unload Form1 ' oubien Unload Me '<- parfois plus simple pour se relire
End Sub
'
'
Private Sub ChangeAscenseur(Etage As Integer)
Dim i As Integer
Shape(Etage).FillStyle = 0
For i = 1 To 8
If i <> Etage Then Shape(i).FillStyle = 1
Next i

End Sub


Private Sub carte(test As Integer)
ClearAllDigital
Dim i As Integer


For i = 0 To 8 '<- inversion à regler d'urgence
If i <> test Then SetDigitalChannel i Next i
End Sub


Private Sub Frame6_DragDrop(Source As Control, X As Single, Y As Single)


End Sub


Private Sub Timer1_Timer()
Timer1.Enabled = False
Dim i As Long
i = ReadAllDigital
Check2(0).Value = (i And 1)
Check2(1).Value = (i And 2) / 2
Check2(2).Value = (i And 4) / 4
Check2(3).Value = (i And 8) / 8
Check2(4).Value = (i And 16) / 16
Timer1.Enabled = True
End Sub

comment dire que si
check2 = true ( tous le check2)
alors command ( indexé de 1 à 8) .visible = false

merci

1 réponse

Messages postés
34
Date d'inscription
lundi 6 janvier 2003
Statut
Membre
Dernière intervention
29 mars 2008

Dim bLoop As Byte, bChecked As Byte

For bLoop = 0 To 4 If Check2(bLoop).Value 1 Then bChecked bChecked + 1
Next

If Not bChecked = 4 Then
For bLoop = 1 To 8
Command(bLoop).Visible = False
Next
End If

Frank150
3
Merci

Quelques mots de remerciements seront grandement appréciés. Ajouter un commentaire

Codes Sources 109 internautes nous ont dit merci ce mois-ci