?? form1.frm
字號:
VERSION 5.00
Begin VB.Form Form1
Caption = "Saro VB SMS Demo V3.3"
ClientHeight = 6855
ClientLeft = 540
ClientTop = 405
ClientWidth = 11415
Icon = "Form1.frx":0000
LinkTopic = "Form1"
ScaleHeight = 6855
ScaleWidth = 11415
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame4
Caption = "發送區"
Height = 2610
Left = 5295
TabIndex = 12
Top = 4140
Width = 6015
Begin VB.Timer Timer1
Interval = 300
Left = 5400
Top = 1500
End
Begin VB.CommandButton Command_send
Caption = "發送"
Height = 360
Left = 4890
TabIndex = 17
Top = 2160
Width = 855
End
Begin VB.TextBox Text_phone
Height = 300
Left = 1275
TabIndex = 16
Text = "13799273095"
Top = 2175
Width = 1455
End
Begin VB.TextBox Text_send
Height = 1815
Left = 75
MaxLength = 140
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 14
Text = "Form1.frx":1CCA
Top = 180
Width = 5850
End
Begin VB.Label Label4
Caption = "對方號碼:"
Height = 225
Left = 210
TabIndex = 15
Top = 2205
Width = 930
End
End
Begin VB.Frame Frame3
Caption = "接收區"
Height = 3000
Left = 5310
TabIndex = 11
Top = 1035
Width = 6000
Begin VB.TextBox Text_rec
Height = 2730
Left = 75
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 13
Top = 165
Width = 5850
End
End
Begin VB.CommandButton Command_stop
Caption = "停止"
Height = 375
Left = 9300
TabIndex = 3
Top = 360
Width = 870
End
Begin VB.Frame Frame2
Caption = "狀態顯示區"
Height = 5850
Left = 75
TabIndex = 2
Top = 930
Width = 5115
Begin VB.TextBox Text_sd
Height = 5535
Left = 75
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 10
Top = 225
Width = 4935
End
End
Begin VB.CommandButton Command_start
Caption = "開始"
Height = 375
Left = 8250
TabIndex = 0
Top = 360
Width = 930
End
Begin VB.Frame Frame1
Caption = "設置區"
Height = 735
Left = 75
TabIndex = 1
Top = 135
Width = 11220
Begin VB.CommandButton Command1
Caption = "清空"
Height = 375
Left = 10215
TabIndex = 18
Top = 225
Width = 870
End
Begin VB.TextBox Text_csca
Height = 300
Left = 5805
TabIndex = 9
Top = 240
Width = 2160
End
Begin VB.ComboBox Combo_baud
Height = 300
ItemData = "Form1.frx":1CDE
Left = 3120
List = "Form1.frx":1CEE
TabIndex = 7
Text = "57600"
Top = 270
Width = 1035
End
Begin VB.ComboBox Combo_com
Height = 300
ItemData = "Form1.frx":1D0E
Left = 735
List = "Form1.frx":1D2D
TabIndex = 5
Text = "COM1"
Top = 270
Width = 1005
End
Begin VB.Label Label3
Caption = "短信中心號碼:"
Height = 285
Left = 4500
TabIndex = 8
Top = 300
Width = 1185
End
Begin VB.Label Label2
Caption = "波特率:"
Height = 270
Left = 2370
TabIndex = 6
Top = 315
Width = 795
End
Begin VB.Label Label1
Caption = "串口:"
Height = 255
Left = 150
TabIndex = 4
Top = 315
Width = 555
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command_send_Click()
If Me.Text_send.Text <> "" Then
Dim index As Long
'Dim Msg() As Byte
' Dim phone() As Byte
' Msg = StrConv(Me.Text_send.Text, vbFromUnicode)
' phone = StrConv(Me.Text_phone.Text, vbFromUnicode)
index = SMSSendMessage(Me.Text_send.Text, Me.Text_phone.Text)
End If
End Sub
Private Sub Command_start_Click()
Dim com As Integer
Dim baud As Long
Dim suc As Long
Dim err As String
com = Int(Mid(Me.Combo_com.Text, 4))
baud = CLng(Me.Combo_baud.Text)
If Me.Text_csca.Text = "" Then
suc = SMSDef.SMSStartService(com, baud, 2, 8, 0, 0, "card") '如果想用SIM卡內的短信中心號碼,請把最后一個參數設為"card"(小寫)
Else
suc = SMSDef.SMSStartService(com, baud, 2, 8, 0, 0, Me.Text_csca.Text)
End If
If suc = 1 Then
Me.Command_start.Enabled = False
Me.Command_stop.Enabled = True
Me.Command_send.Enabled = True
Me.Text_sd.SelText = "啟動成功" & vbCrLf
Me.Timer1.Enabled = True
Else
Me.Command_start.Enabled = True
Me.Command_stop.Enabled = False
Me.Command_send.Enabled = False
Me.Text_sd.SelText = "啟動失敗" & vbCrLf
err = "這里填一些字符,以免SMSGetLastError內操作此字符串時溢出,在SMSGetLastError該字符串定義為1024byte"
SMSGetLastError err
Me.Text_sd.SelText = err
Me.Text_sd.SelText = vbCrLf
End If
End Sub
Private Sub Command_stop_Click()
Me.Timer1.Enabled = False
SMSStopSerice
Me.Command_start.Enabled = True
Me.Command_stop.Enabled = False
Me.Command_send.Enabled = False
Me.Text_sd.SelText = "停止成功" & vbCrLf
End Sub
Private Sub Command1_Click()
Me.Text_sd.Text = ""
Me.Text_rec.Text = ""
End Sub
Private Sub Form_Unload(Cancel As Integer)
SMSStopSerice '關閉窗口前先關閉服務,否則在VB中有時會報錯。
End Sub
Private Sub Timer1_Timer()
Dim smg As SMSMessageStruct
Dim srs As SMSReportStruct
If SMSReport(srs) <> 0 Then
If srs.Success = 1 Then
Me.Text_sd.SelText = "發往" & StrConv(srs.PhoneNo, vbUnicode)
Me.Text_sd.SelText = "的短信發送成功,內容:" & StrConv(srs.Msg, vbUnicode)
Me.Text_sd.SelText = vbCrLf
Else
Me.Text_sd.SelText = "發往" & StrConv(srs.PhoneNo, vbUnicode)
Me.Text_sd.SelText = "的短信發送失敗,內容:" & StrConv(srs.Msg, vbUnicode)
Me.Text_sd.SelText = vbCrLf
End If
End If
If SMSGetNextMessage(smg) = 1 Then
Me.Text_rec.SelText = "收到短信:<" & StrConv(smg.ReceTime, vbUnicode)
Me.Text_rec.SelText = "> <" & StrConv(smg.PhoneNo, vbUnicode)
Me.Text_rec.SelText = ">:" & vbCrLf & " " & StrConv(smg.Msg, vbUnicode)
Me.Text_rec.SelText = vbCrLf
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -