Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

HI i Am trying to make programme which can send message using Usb Modem I ball 3.5 g connect i found code from internet but when i run that code it gives message send but no message are send i have sams pack and also recharge in my airtel sim card please help me.I request you if you can suggest me any working code any other method to send sms using usb modem ,i know web service bu in my area it cannot be possible i can use only gsm modem.

Imports System
Imports System.Threading
Imports System.ComponentModel
Imports System.IO.Ports

Public Class Form1
    'connect your mobile/GSM modem to PC,
    'then go in device manager and check under ports which COM port has been slected
    'if say com1 is there then put com2 in following statement
    Dim SMSEngine As New SMSCOMMS("COM19")
    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

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    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 = 9600
            .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 = True Then



            'sending AT commands
            SMSPort.WriteLine("AT")
            SMSPort.WriteLine("AT+CMGF=1" & vbCrLf) 'set command message format to text mode(1)
            SMSPort.WriteLine("AT+CSCA=""+919831029416""" & 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
            _ContSMS = False
            SMSPort.WriteLine("+ TextBox1.text +" & vbCrLf & Chr(26)) 'SMS sending

            MessageBox.Show(":send")
            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
question from:https://stackoverflow.com/questions/66061965/send-sms-using-usb-iball-3-5-connect-in-vb-net

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
149 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...