1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| Private Sub Form_Load()
Declaration des variables
Dim PortActif As Integer
Dim PremierChoix As Integer
Dim NumPort As Integer
PremierChoix = 0
PortActif = 0
Test des ports actifs et pas ouverts pour la création du menu
For NumPort = 1 To 15
On Error Resume Next
MSComm1.CommPort = NumPort
MSComm1.PortOpen = True
If Err.Number <> 8002 Or Err.Number <> 0 Then
Load choix(NumPort)
choix(NumPort).Caption = NumPort
choix(NumPort).Visible = True
MSComm1.PortOpen = False
End If
Next NumPort
End Sub
Private Sub choix_Click(ChoixPortActif As Integer)
Premier fois que on fait un choix du port com
If PremierChoix = 0 Then
PremierChoix = 1
PortActif = ChoixPortActif
choix(ChoixPortActif).Checked = True
MSComm1.CommPort = ChoixPortActif
MSComm1.PortOpen = True
End If
Choix suivant du port com et control si pas le même (choisir une deuxième fois le même port com)
If PremierChoix <> 0 And PortActif <> ChoixPortActif Then
choix(PortActif).Checked = False
MSComm1.CommPort = PortActif
MSComm1.PortOpen = False
PortActif = ChoixPortActif
choix(ChoixPortActif).Checked = True
MSComm1.CommPort = ChoixPortActif
MSComm1.PortOpen = True
End If
End Sub |
Partager