Bonjour, j'éssaie depuis bientôt deux semaines d'envoyer un sms via un modem usb en VB.NET mais en vain.
j'ai ce bout de code qui semble s'exécuter normalement mais je ne reçois pas de message.

Code VB.NET : Sélectionner tout - Visualiser dans une fenêtre à part
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
Imports System
Imports System.Threading
Imports System.ComponentModel
Imports System.IO.Ports
 
Public Class Form1
 
    Dim SMSEngine As New SMSCOMMS("COM13")
    Dim i As Integer
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 
 
        SMSEngine.Open() 'open the port
        SMSEngine.SendSMS() 'send the SMS
        MsgBox("ook envoi")
 
    End Sub
 
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
 
        Dim ports As String() = SerialPort.GetPortNames
            Dim port As String
 
        For Each port In ports
                ComboBox1.Items.Add(port)
            Next port
            ComboBox1.SelectedIndex = 0
 
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
 
    End Sub
End Class
Public Class SMSCOMMS
    Private WithEvents SMSPort As SerialPort
    Private SMSThread As Thread
    Private ReadThread As Thread
    Shared _Continue As Boolean = False
    Shared _ContSMS As Boolean = False
    Private _Wait As Boolean = False
    Shared _ReadPort As Boolean = False
    Public Event Sending(ByVal Done As Boolean)
    Public Event DataReceived(ByVal Message As String)
 
    Public Sub New(ByRef COMMPORT As String)
        'initialize all values
        SMSPort = New SerialPort
        With SMSPort
            .PortName = COMMPORT
            .BaudRate = 19200
            .Parity = Parity.None
            .DataBits = 8
            .StopBits = StopBits.One
            .Handshake = Handshake.RequestToSend
            .DtrEnable = True
            .RtsEnable = True
            .NewLine = vbCrLf               
        End With
    End Sub
    Public Function SendSMS() As Boolean
        If SMSPort.IsOpen Then
            SMSPort.Close()
        End If
        If SMSPort.IsOpen = True Then
            'sending AT commands
            SMSPort.WriteLine("AT")
            SMSPort.WriteLine("AT+CFUN=1")
            SMSPort.WriteLine("AT+CMGF=1" & vbCrLf) 'set command message format to text mode(1)
            SMSPort.WriteLine("AT+CSCA=""+22507070002""" & vbCrLf) 'set service center address (which varies for service providers (idea, airtel))
            SMSPort.WriteLine("AT+CMGS=  + TextBox1.text + " & vbCrLf) ' enter the mobile number whom you want to send the SMS
 
            'SMSPort.WriteLine("ATDT +22577083978" & vbCrLf)
            _ContSMS = False
            '   SMSPort.WriteLine("+ TextBox1.text +" & vbCrLf & Chr(26)) 'SMS sending
            '   SMSPort.WriteLine("TextBox2.text")
            MessageBox.Show(":send")
            SMSPort.WriteLine("AT+CFUN=0")
            SMSPort.Close()
        End If
    End Function
 
    Public Sub Open()
        If Not (SMSPort.IsOpen = True) Then
            SMSPort.Open()
        End If
    End Sub
 
    Public Sub Close()
        If SMSPort.IsOpen = True Then
            SMSPort.Close()
        End If
    End Sub
End Class

merci d'avance.
cordialement