📄 form1.frm
字号:
VERSION 5.00
Object = "{808FE5E1-BBDC-4A70-8C88-D3F1B1EC2433}#1.0#0"; "smscontrol.ocx"
Begin VB.Form Form1
Caption = "SMS控件实例"
ClientHeight = 8385
ClientLeft = 60
ClientTop = 345
ClientWidth = 6270
LinkTopic = "Form1"
ScaleHeight = 8385
ScaleWidth = 6270
StartUpPosition = 3 'Windows Default
Begin VB.Frame Frame3
Caption = "配置"
Height = 2175
Left = 360
TabIndex = 12
Top = 5760
Width = 4815
Begin VB.CommandButton Command2
Caption = "确认配置并打开串口"
Height = 375
Left = 960
TabIndex = 17
Top = 1800
Width = 2055
End
Begin VB.TextBox Text6
Height = 375
Left = 1680
TabIndex = 16
Text = "Text6"
Top = 1320
Width = 1815
End
Begin VB.TextBox Text5
Height = 375
Left = 1680
TabIndex = 15
Text = "Text5"
Top = 480
Width = 1695
End
Begin VB.Label Label6
Caption = "短信中心号码"
Height = 375
Left = 360
TabIndex = 14
Top = 1440
Width = 1095
End
Begin VB.Label Label5
Caption = "串口号:"
Height = 375
Left = 480
TabIndex = 13
Top = 480
Width = 855
End
End
Begin SMSCONTROLLib.Smscontrol Smscontrol1
Height = 495
Left = 0
TabIndex = 11
Top = 840
Visible = 0 'False
Width = 495
_Version = 65536
_ExtentX = 873
_ExtentY = 873
_StockProps = 0
End
Begin VB.Frame Frame2
Caption = "收"
Height = 2775
Left = 480
TabIndex = 6
Top = 2760
Width = 4695
Begin VB.TextBox Text4
Height = 1695
Left = 1440
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 8
Text = "Form1.frx":0000
Top = 960
Width = 3015
End
Begin VB.TextBox Text3
Height = 375
Left = 1560
TabIndex = 7
Text = "Text3"
Top = 240
Width = 2895
End
Begin VB.Label Label4
Caption = "短信内容"
Height = 375
Left = 360
TabIndex = 10
Top = 1080
Width = 975
End
Begin VB.Label Label3
Caption = "对方号码 "
Height = 375
Left = 480
TabIndex = 9
Top = 240
Width = 975
End
End
Begin VB.Frame Frame1
Caption = "发 "
Height = 2295
Left = 480
TabIndex = 0
Top = 240
Width = 4575
Begin VB.CommandButton Command1
Caption = "发短信"
Height = 375
Left = 1800
TabIndex = 3
Top = 1920
Width = 1095
End
Begin VB.TextBox Text2
Height = 975
Left = 1440
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 2
Text = "Form1.frx":0006
Top = 840
Width = 2895
End
Begin VB.TextBox Text1
Height = 405
Left = 1440
TabIndex = 1
Text = "Text1"
Top = 240
Width = 2895
End
Begin VB.Label Label2
Caption = "短信内容"
Height = 495
Left = 480
TabIndex = 5
Top = 1080
Width = 855
End
Begin VB.Label Label1
Caption = "对方号码 "
Height = 375
Left = 480
TabIndex = 4
Top = 360
Width = 855
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim phone As String
Dim msg As String
phone = Text1
msg = Text2
'请在这里加上手机号和短信内容的合法分析
result = Smscontrol1.SendMSG(phone, msg)
If result = 0 Then
'这里加上成功提示.返回0表示成功,其他表示失败
End If
End Sub
Private Sub Command2_Click()
Smscontrol1.nCommPort = Text5 '改为你所用的串口号
Smscontrol1.strMSCA = Text6 '改为当地短信中心号码
resultopen = Smscontrol1.OpenComm() '只有现打开串口后才能收发短信
If resultopen <> 0 Then '返回0表示成功,其他表示失败
Text2 = "打开串口失败"
End If
End Sub
Private Sub Form_Load()
Text5 = 1
Text6 = "+8613800812500"
End Sub
Private Sub Smscontrol1_OnRecvMsg()
Dim msca As String
Dim oa As String
Dim msgrcv As String
Dim timestamp As String
resultrcv = Smscontrol1.ReadMsgForVB(msca, oa, msgrcv, timestamp)
If resultrcv = 0 Then '返回0表示读到短信
Text3 = oa
Text4 = msgrcv
Else
Text4 = "recieve error"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -