Private Sub ToggleButton1_Click()
Dim i As Long
Static OnProcess As Boolean
If ToggleButton1.Value Then
ToggleButton1.Caption = "Acquisition en cours"
OnProcess = True
'Vider le buffer
NETComm1.InBufferCount = 0
'choisir un port série
NETComm1.CommPort = 1 'Ici
'Balance
'9600 bauds, impaire, 8 bits de données, 1 bit d'arrêt
NETComm1.Settings = "9600,n,8,1" 'Ici
' indique au contrôle qu'il doit lire 1 seul caractère
'ce caractère sert à repérer la stabilisation de la balance
NETComm1.InputLen = 1 'Ici
'ouvre le port
NETComm1.PortOpen = True
Do While OnProcess
'Boucle tant que le 1er caractère n'est pas un signe plus (+)
Do While NETComm1.InputData <> "+" 'Ici
Loop
'lecture sur le port des 8 1ers caractères et stockage dans la boite de dialogue et dans la feuille active
NETComm1.InputLen = 8
t = Timer + 4
Do Until Timer > t
Loop
i = i + 1
ActiveCell.Offset(i, 0) = NETComm1.InputData
Loop
Else
OnProcess = False
ToggleButton1.Caption = "Attente Acquisition "
NETComm1.PortOpen = False
End If
End Sub