📄 frmdemo.frm
字号:
VERSION 5.00
Object = "{672A266B-73CB-434C-A65C-CEFC6DEF262B}#1.1#0"; "TransoftSMSControl.ocx"
Begin VB.Form frmDemo
BorderStyle = 1 'Fixed Single
Caption = "短信控件使用示例(vb6.0)"
ClientHeight = 4800
ClientLeft = 45
ClientTop = 330
ClientWidth = 7485
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4800
ScaleWidth = 7485
StartUpPosition = 2 'CenterScreen
Begin VB.Frame Frame4
Caption = "读短信"
Height = 615
Left = 30
TabIndex = 22
Top = 3660
Width = 7305
Begin VB.TextBox txtReadResult
Height = 300
Left = 2700
TabIndex = 26
Top = 210
Width = 4545
End
Begin VB.CommandButton cmdRead
Caption = "读短信(&R)"
Height = 345
Left = 1560
TabIndex = 25
Top = 180
Width = 1095
End
Begin VB.TextBox txtSMSNo
Height = 300
Left = 930
TabIndex = 24
Top = 210
Width = 555
End
Begin VB.Label Label7
Caption = "短信编号"
Height = 225
Left = 210
TabIndex = 23
Top = 270
Width = 735
End
End
Begin TransoftSMSControl.SMS SMS
Height = 495
Left = 5790
Top = 4290
Visible = 0 'False
Width = 495
_ExtentX = 873
_ExtentY = 873
End
Begin VB.CommandButton cmdClose
Caption = "关闭(&C)"
Height = 345
Left = 6300
TabIndex = 17
Top = 4410
Width = 1065
End
Begin VB.Frame Frame3
Caption = "短信接收"
Height = 2535
Left = 3750
TabIndex = 10
Top = 1080
Width = 3615
Begin VB.TextBox txtRec
Height = 2115
Left = 60
MultiLine = -1 'True
TabIndex = 18
Top = 360
Width = 3495
End
End
Begin VB.Frame Frame2
Caption = "发短信"
Height = 2535
Left = 30
TabIndex = 9
Top = 1080
Width = 3585
Begin VB.CommandButton cmdSend
Caption = "发送(&S)"
Height = 345
Left = 2430
TabIndex = 20
Top = 2130
Width = 1035
End
Begin VB.TextBox txtMobileNo
Height = 270
Left = 870
TabIndex = 15
Top = 690
Width = 2625
End
Begin VB.CheckBox chkReport
Caption = "状态报告"
Height = 225
Left = 1830
TabIndex = 13
Top = 330
Width = 1245
End
Begin VB.CheckBox chkChinese
Caption = "中文短信"
Height = 285
Left = 210
TabIndex = 12
Top = 330
Value = 1 'Checked
Width = 1155
End
Begin VB.TextBox txtmsg
Height = 1035
Left = 870
MultiLine = -1 'True
TabIndex = 11
Top = 1050
Width = 2595
End
Begin VB.Label Label2
Caption = "短信内容"
Height = 195
Left = 90
TabIndex = 19
Top = 1020
Width = 855
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "手机号码"
Height = 180
Left = 90
TabIndex = 14
Top = 720
Width = 720
End
End
Begin VB.Frame Frame1
Caption = "连接手机"
Height = 915
Left = 30
TabIndex = 0
Top = 120
Width = 7335
Begin VB.ComboBox cboRate
Height = 300
ItemData = "frmDemo.frx":0000
Left = 3960
List = "frmDemo.frx":001C
TabIndex = 27
Text = "9600,n,8,1"
Top = 210
Width = 2235
End
Begin VB.CheckBox chkAutoRec
Caption = "自动接收"
Height = 210
Left = 5190
TabIndex = 16
Top = 600
Value = 1 'Checked
Width = 1035
End
Begin VB.CommandButton cmdDisConnect
Caption = "断开(&D)"
Height = 285
Left = 6270
TabIndex = 8
Top = 510
Width = 975
End
Begin VB.CommandButton cmdConnect
Caption = "连接(&C)"
Height = 285
Left = 6270
TabIndex = 7
Top = 180
Width = 975
End
Begin VB.ComboBox cboMobileType
Height = 300
ItemData = "frmDemo.frx":0087
Left = 1260
List = "frmDemo.frx":0097
Style = 2 'Dropdown List
TabIndex = 3
Top = 210
Width = 1665
End
Begin VB.ComboBox cboSMSPort
Height = 300
ItemData = "frmDemo.frx":00C9
Left = 3990
List = "frmDemo.frx":00DC
Style = 2 'Dropdown List
TabIndex = 2
Top = 555
Width = 1155
End
Begin VB.TextBox txtCenterNo
Alignment = 1 'Right Justify
Height = 270
Left = 1260
TabIndex = 1
Text = "8613800100500"
Top = 555
Width = 1665
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "速率选择:"
Height = 180
Left = 3090
TabIndex = 28
Top = 300
Width = 810
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "手机类型:"
Height = 180
Left = 450
TabIndex = 6
Top = 285
Width = 810
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "短信中心号码:"
Height = 180
Left = 90
TabIndex = 5
Top = 615
Width = 1170
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "串口选择:"
Height = 180
Left = 3090
TabIndex = 4
Top = 630
Width = 810
End
End
Begin VB.Label Label3
Caption = "特别提示:对于Nokia手机,必须安装DataSuite驱动程序,而且驱动程序自动将连接虚拟成了串口3"
ForeColor = &H000000FF&
Height = 405
Left = 60
TabIndex = 21
Top = 4320
Width = 5955
End
End
Attribute VB_Name = "frmDemo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'//////////////////////////////////////////////////////
'
'
'本程序展示了短信控件的核心功能,希望能为您使用控件提供帮助
'
'
'
'//////////////////////////////////////////////////////
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdConnect_Click()
If chkAutoRec.Value = 1 Then '判断是否要打开自动接收短信功能
SMS.AutoReceive = True
Else
SMS.AutoReceive = False
End If
Select Case cboMobileType.Text '读手机类型
Case "标准手机"
SMS.MobileType = 0
Case "Wavecom模块"
SMS.MobileType = 1
Case "Nokia手机"
SMS.MobileType = 2
Case "西门子手机"
SMS.MobileType = 3
Case Else
End Select
'设置串口号
If cboSMSPort.Text <> "" Then SMS.CommPort = Right(cboSMSPort.Text, 1)
'设置中心号码
SMS.CenterNo = txtCenterNo.Text
'设置波特率
SMS.Settings = cboRate.Text
'打开与手机的通讯
If SMS.CommOpen = 0 Then
MsgBox "连接成功!"
Else
MsgBox "连接失败!"
End If
End Sub
Private Sub cmdDisConnect_Click()
'关闭与手机的连接
SMS.CommClose
MsgBox "断开成功!"
End Sub
Private Sub cmdRead_Click()
If txtSMSNo.Text <> "" Then
If SMS.ReadMsg(txtSMSNo.Text) = 0 Then
'从控件的属性中取得刚才读出的短信内容
txtReadResult.Text = SMS.LastReadTime & "|" & SMS.LastReadSender & "|" & SMS.LastReadMsg
Else
MsgBox "读短信息失败!"
End If
End If
End Sub
Private Sub cmdSend_Click()
If SMS.SendMsg(txtMobileNo.Text, txtmsg.Text, IIf((chkChinese.Value = 1), True, False), IIf((chkReport.Value = 1), True, False)) = 0 Then
MsgBox "发送成功!"
Else
MsgBox "发送失败!"
End If
End Sub
Private Sub Form_Load()
cboMobileType.Text = "标准手机"
cboSMSPort.Text = "COM1"
End Sub
Private Sub SMS_MsgReceived(ByVal MsgSender As String, ByVal Msg As String, ByVal ArrivedTime As Date)
txtRec = txtRec & "[" & ArrivedTime & "]" & MsgSender & ":" & Msg & vbCrLf
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -