📄 test.frm
字号:
VERSION 5.00
Object = "{622B0081-6F39-4A0B-8EFC-810EB9861BE1}#1.0#0"; "GsmCtl_S.Ocx"
Begin VB.Form Test
BorderStyle = 3 'Fixed Dialog
Caption = "控件测试程序 - 馨通软件工作室"
ClientHeight = 5130
ClientLeft = 45
ClientTop = 330
ClientWidth = 8685
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5130
ScaleWidth = 8685
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame7
Caption = "电话簿区"
Height = 2115
Left = 30
TabIndex = 8
Top = 2910
Width = 4305
Begin VB.TextBox TxtPhoneNum
BeginProperty Font
Name = "Fixedsys"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 2520
TabIndex = 14
Top = 1710
Width = 1725
End
Begin VB.TextBox TxtName
Height = 315
Left = 1410
TabIndex = 13
Text = "姓名"
Top = 1710
Width = 1065
End
Begin VB.CommandButton CmdFunc
Caption = "Write"
Height = 315
Index = 7
Left = 90
TabIndex = 12
Top = 1710
Width = 1245
End
Begin VB.CommandButton CmdFunc
Caption = "Delete"
Height = 765
Index = 6
Left = 2940
TabIndex = 11
Top = 930
Width = 1245
End
Begin VB.CommandButton CmdFunc
Caption = "ReadAll"
Height = 765
Index = 5
Left = 2940
TabIndex = 10
Top = 180
Width = 1245
End
Begin VB.ListBox LstBook
Height = 1500
Left = 90
TabIndex = 9
Top = 180
Width = 2805
End
End
Begin VB.Frame Frame4
Caption = "短信区"
Height = 2895
Left = 0
TabIndex = 1
Top = 0
Width = 8625
Begin VB.Frame Frame9
Caption = "读取短信"
Height = 585
Left = 4350
TabIndex = 19
Top = 2190
Width = 4215
Begin VB.CommandButton CmdFunc
Caption = "ReadSMS"
Height = 345
Index = 9
Left = 3030
TabIndex = 22
Top = 180
Width = 1065
End
Begin VB.TextBox TxtIndex1
Height = 270
Left = 2370
TabIndex = 20
Text = "1"
Top = 210
Width = 525
End
Begin VB.Label Label2
Caption = "短信编号:"
Height = 255
Left = 1290
TabIndex = 21
Top = 240
Width = 1035
End
End
Begin VB.Frame Frame8
Caption = "删除短信"
Height = 585
Left = 60
TabIndex = 15
Top = 2190
Width = 4215
Begin VB.CommandButton CmdFunc
Caption = "DeleteSMS"
Height = 345
Index = 8
Left = 3030
TabIndex = 18
Top = 150
Width = 1065
End
Begin VB.TextBox TxtIndex
Height = 270
Left = 2370
TabIndex = 17
Text = "1"
Top = 210
Width = 525
End
Begin VB.Label Label1
Caption = "短信编号:"
Height = 255
Left = 1290
TabIndex = 16
Top = 240
Width = 1035
End
End
Begin VB.Frame Frame5
Caption = "发送"
Height = 1875
Left = 60
TabIndex = 2
Top = 210
Width = 4215
Begin VB.TextBox TxtCalledNum
Alignment = 1 'Right Justify
BeginProperty Font
Name = "Fixedsys"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
Left = 1200
MaxLength = 21
TabIndex = 0
Text = "1860"
Top = 180
Width = 2925
End
Begin GsmCtrlOCX_S.GSMCtrl_S GSMCtrl
Height = 615
Left = 2970
TabIndex = 23
Top = 870
Visible = 0 'False
Width = 615
_ExtentX = 1085
_ExtentY = 1085
End
Begin VB.CommandButton CmdFunc
Caption = "SendSMSEx"
Height = 585
Index = 4
Left = 60
TabIndex = 3
Top = 1170
Width = 1125
End
Begin VB.TextBox TxtSendSMS
Height = 1185
Left = 1200
MaxLength = 160
MultiLine = -1 'True
TabIndex = 5
Top = 600
Width = 2925
End
Begin VB.CommandButton CmdFunc
Caption = "SendSMS"
Height = 585
Index = 3
Left = 60
TabIndex = 4
Top = 600
Width = 1125
End
Begin VB.Label Label3
Caption = "目标号码:"
Height = 255
Left = 120
TabIndex = 24
Top = 240
Width = 915
End
End
Begin VB.Frame Frame6
Caption = "接收"
Height = 1875
Left = 4350
TabIndex = 6
Top = 210
Width = 4215
Begin VB.Label LabSMSRev
BackColor = &H8000000E&
Height = 1545
Left = 90
TabIndex = 7
Top = 240
Width = 4035
End
End
End
End
Attribute VB_Name = "Test"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub CmdFunc_Click(Index As Integer)
Static I As Long
Select Case Index
Case 3
If GSMCtrl.SendMessage(TxtCalledNum.Text, TxtSendSMS.Text) Then
Debug.Print "发送成功"
Else
Debug.Print "发送失败"
End If
Case 4
GSMCtrl.SendMessageEx I, TxtCalledNum.Text, TxtSendSMS.Text
I = I + 1
Case 5
Dim j As Integer
Dim strPhoneNum As String
Dim strName As String
CmdFunc(5).Enabled = False
LstBook.Clear
For j = 1 To 10 '读取10条
Call GSMCtrl.ReadPhoneBook(j, strPhoneNum, strName)
If strPhoneNum <> "" Or strName <> "" Then
LstBook.AddItem "[" & j & "]" & strName & ":" & strPhoneNum
LstBook.ListIndex = 0
End If
Next j
CmdFunc(5).Enabled = True
Case 6
CmdFunc(6).Enabled = False
GSMCtrl.DeletePhoneBook Mid(LstBook.List(LstBook.ListIndex), 2, InStr(1, LstBook.List(LstBook.ListIndex), "]") - 2)
CmdFunc(6).Enabled = True
Call CmdFunc_Click(5)
Case 7
If TxtPhoneNum = "" Or TxtName = "" Then
MsgBox "请输入名字和号码!"
Exit Sub
End If
CmdFunc(7).Enabled = False
If GSMCtrl.WritePhoneBook(0, TxtPhoneNum, TxtName.Text) Then
MsgBox "写入成功!"
Else
MsgBox "写入失败!"
End If
CmdFunc(7).Enabled = True
Call CmdFunc_Click(5)
Case 8
If GSMCtrl.DeleteMessage(CInt(TxtIndex.Text)) Then
MsgBox "删除成功!"
Else
MsgBox "删除失败!"
End If
Case 9
Dim strCallingNum As String
Dim strMsg As String
Dim strDate As String
If GSMCtrl.ReadMessage(TxtIndex1.Text, strCallingNum, strMsg, strDate) Then
LabSMSRev.Caption = "号码:" & strCallingNum
LabSMSRev.Caption = LabSMSRev.Caption & vbCrLf & "日期:" & strDate
LabSMSRev.Caption = LabSMSRev.Caption & vbCrLf & "内容:" & vbCrLf & strMsg
Else
LabSMSRev.Caption = "无短信"
End If
End Select
End Sub
Private Sub Form_Load()
GSMCtrl.TimeOut = 5000
GSMCtrl.FlashSMS = False
If GSMCtrl.InitDevice(1, "115200,N,8,1") Then
MsgBox "成功"
Else
MsgBox "失败"
End If
End Sub
Private Sub GSMCtrl_ComReceive(RevStr As String)
Debug.Print RevStr
End Sub
Private Sub GSMCtrl_SMSRev(CallingNum As String, Msg As String, SendDate As String)
LabSMSRev.Caption = "号码:" & CallingNum
LabSMSRev.Caption = LabSMSRev.Caption & vbCrLf & "日期:" & SendDate
LabSMSRev.Caption = LabSMSRev.Caption & vbCrLf & "内容:" & vbCrLf & Msg
End Sub
Private Sub GSMCtrl_SMSSendStatus(ID As Long, Status As Boolean)
If Status Then
Debug.Print Now & "短信发送成功,ID:" & ID
Else
Debug.Print Now & "短信发送失败,ID:" & ID
End If
End Sub
Private Sub TxtCalledNum_KeyPress(KeyAscii As Integer)
If KeyAscii <> Asc("+") And (KeyAscii < Asc("0") Or KeyAscii > Asc("9")) Then
KeyAscii = 0
End If
End Sub
Private Sub TxtPhoneNum_KeyPress(KeyAscii As Integer)
If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then
KeyAscii = 0
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -