通过VB发送短信6 [英] Sending SMS Through VB 6

查看:96
本文介绍了通过VB发送短信6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

关于SMS,通过VB6应用程序,我们如何发送短信设备连接到USB端口的短信。任何有这些信息的人请告诉我。

关于,Jay。

Hi All,

Regarding SMS, through VB6 application, how can we send the SMS where a SMS device is Connected to USB Port. Anybody having the information please let me know.

Regards,
Jay.

推荐答案

你几乎肯定需要第三方库。我怀疑是否有人仍在编写或支持VB6的那些,因为它是如何过时和过时的

如果VB6可以与Web服务通信,您可能会找到一个可以使用的Web服务。我怀疑它是免费的。

you will almost certainly need a third party library. I doubt anyone still writes or supports those for VB6 tho, given how out of date and obsolete it is

If VB6 can talk to a webservice, you may find a webservice you can use. I doubt it would be free.


进口系统

进口System.Threading

进口System.ComponentModel

Imports System.IO.Ports



Public Class Form1

'将您的手机/ GSM调制解调器连接到PC,

'然后进入设备管理器并检查COM端口已被选中的端口

'如果说com1在那里然后将com2放入以下声明中

Dim SMSEngine As New SMSCOMMS(COM19)

Dim i As Integer



Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System。 EventArgs)处理Button1.Click



SMSEngine.Open()'打开端口

SMSEngine.SendSMS()'发送短信



结束次级

结束班级



公共类SMSCOMMS

Private WithEvents SMSPort作为SerialPort

私有SMSThread作为线程

Priva te ReadThread As Thread

Shared _Continue As Boolean = False

共享_ContSMS As Boolean = False

Private _Wait As Boolean = False

共享_ReadPort As Boolean = False

公共事件发送(ByVal Done As Boolean)

公共事件DataReceived(ByVal消息为字符串)



Public Sub New(ByRef COMMPORT As String)

'初始化所有值

SMSPort =新SerialPort

使用SMSPort

.PortName = COMMPORT

.BaudRate = 19200

.Parity = Parity.None

。 DataBits = 8

.StopBits = StopBits.One

.Handshake = Handshake.RequestToSend

.DtrEnable = True

.RtsEnable = True

.NewLine = vbCrLf

结束

结束子



Public Function SendSMS()As Boolean

如果SMSPort.IsOpen = True那么

'发送AT命令

SMSPort。 WriteLine(AT)

SMSPort.WriteLine(AT + CMGF = 1&vbCrLf)'将命令消息格式设置为文本模式(1)

SMSPort.WriteLine (AT + CSCA =+ 919822078000和vbCrLf'设置服务中心地址(因服务提供商(想法,airtel)而异)

SMSPort.WriteLine(AT + CMGS = + TextBox1.text +&vbCrLf'输入您要发送短信的手机号码

_ContSMS = False

SMSPort.WriteLine(+ TextBox1.text + &vbCrLf&Chr(26))'短信发送

MessageBox.Show(:发送)

SMSPort.Close()

结束如果

结束功能



Public Sub Open()

如果不是(SMSPort.IsOpen = True)然后

SMSPort.Open()

结束如果

结束子



公共子关闭()

如果SMSPort.IsOpen = True那么

SMSPort.Close()

结束如果

结束子

End Class
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
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 = 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=""+919822078000""" & 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


; P; P; P哦,天啊,这是我的中期项目她在sti中
;P ;P ;P oh may god thats my midterm project her in sti


这篇关于通过VB发送短信6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆