Une image vous présente les controles a placer.
Source / Exemple :
Public Max
Dim Numtel(30)
Dim Nomtel(30)
Private Sub COM1_Click()
MSComm1.CommPort = 1
COM1.Checked = True
COM2.Checked = False
COM3.Checked = False
COM4.Checked = False
End Sub
Private Sub COM2_Click()
MSComm1.CommPort = 2
COM1.Checked = False
COM2.Checked = True
COM3.Checked = False
COM4.Checked = False
End Sub
Private Sub COM3_Click()
MSComm1.CommPort = 3
COM1.Checked = False
COM2.Checked = False
COM3.Checked = True
COM4.Checked = False
End Sub
Private Sub COM4_Click()
MSComm1.CommPort = 4
COM1.Checked = False
COM2.Checked = False
COM3.Checked = False
COM4.Checked = True
End Sub
Private Sub Command1_Click()
' Définition des paramétres du port
MSComm1.Settings = "300,N,8,1"
'ouverture du port
On Error Resume Next
MSComm1.PortOpen = True
If Err Then
st = "COM" + Str(MSComm1.CommPort) + " n'est pas disponible."
st = st + "Utilisez le menu Port pour séléctionner un autre port de communication."
MsgBox st
Exit Sub
End If
' Purge du tampon d'entrée
cde = "ATDT " + Numéro.Text + ";" + Chr$(13)
MSComm1.Output = cde
' Attente de la chaine OK en provenance du modem
ok = False
Do
' S'il y a des données dans le tampon , les lit.
If MSComm1.InBufferCount Then
modem = modem + MSComm1.Input
If InStr(modem, "OK") <> 0 Then
MsgBox "Décrochez le téléphone et appuyez sur le bouton OK."
ok = True
End If
End If
Loop Until ok = True
'déconnexion
MSComm1.Output = "ATH" + Chr$(13)
'Fermeture du port
MSComm1.PortOpen = False
End Sub
Private Sub Form_Load()
Open "c:\agend.dat" For Input As #1
i = 1
Do
Line Input #1, Nomtel(i)
Line Input #1, Numtel(i)
Nom.AddItem Nomtel(i)
i = i + 1
Loop Until EOF(1)
Max = i - 1
CommPort = 1
close #1
If COM1.Checked Then MSComm1.CommPort = 1
If COM2.Checked Then MSComm1.CommPort = 2
If COM3.Checked Then MSComm1.CommPort = 3
If COM4.Checked Then MSComm1.CommPort = 4
End Sub
Private Sub Nom_Change()
For i = 1 To Max
If Nomtel(i) = Nom.Text Then
Numéro.Text = Numtel(i)
End If
Next i
End Sub
Conclusion :
"Code éducatif"
@+
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.