Dim arr As String
Public STR As String, PhoneNumber As String, RecvDate As String
Public Flag As Integer
Private Sub Form1_Load ()
If Form2.Com m1. PortOpen=False Then
Form2.Com m1. PortOpen=True
End the If
Form2.Com m1. RThreshold=Form2.Com m1. InBufferCount
Form2.Com m1. An InputMode=comInputModeText
Timer1. Enabled=True
End Sub
Private Sub CmdClear_Click ()
TextData. Text=""
End Sub
Private Sub CmdIDok_Click ()
Dim As a String
Dim As Integer b
A=Trim (Combo1. Text)
B=Len (a)
If b & lt;> 11 Then
MsgBox "I'm sorry, input number error, please input again!" , vbOKOnly + vbInformation, "message"
The Else
Form2.Com m1. The Output="AT + CMGS=Trim (TxtID. Text)" + CRH (13) + CRH (10)
End the If
End Sub
Private Sub CmdQuit_Click ()
End
End Sub
Private Sub CmdSendOk_Click ()
If Flag=1 Then 'by flags to determine whether a message sent successfully
MsgBox "information sent successfully," vbOKOnly + vbInformation, "message!"
Flag=0
The Else
Dim IntChk As String
IntChk=MsgBox (" sorry, news editor of error, whether or not to edit ", vbOKOnly + vbInformation, "message!" )
If IntChk=vbOK Then
Call CmdIDok_Click
End the If
End the If
End Sub
Private Sub Comm1_OnComm trigger
() 'communicationThe Select Case Form2.Comm1.Com mEvent
Case comEvSend
Case comEvReceive
STR=Trim (Form2.Com m1. Input)
Case comEvCTS
Case comEvDSR
Case comEvCD
Case comEvRing
Case comEvEOF
Case comEventBreak
Case comEventFrame
Case comEventOverrun
Case comEventRxOver
Case comEventRxParity
Case comEventTxFull
Case comEventDCB
End the Select
If InStr (STR, "& gt;" ) & gt; 0 Then 'judge whether received characters "& gt;"
Form2.Com m1. The Output=Trim (" CobMesMod. Text "+ CRH (& amp; H1A) + CRH (13) + CRH (10)) 'text messages sent
Flag=1 'logo position 1
The Else
If InStr (STR, "ERROR")=0 Then 'judgment whether receive the new message
TextData.=STR 'Text display Text content
Dim As Integer b
B=InStr (STR, "+ 86")
PhoneNumber=Mid (STR, b + 3, 11) 'read phone number
TextIDNum. Text=PhoneNumber
B=InStr (STR, "+ 32")
RecvDate=Mid (STR, b - 17, 17) 'reading time parameter
TextRecTim. Text=RecvDate
Call GetValue 'read the temperature and humidity information function called
End the If
End the If
End Sub
Private Sub GetValue () 'to read the temperature and humidity information
As the String Dim a, b As String
Dim As Integer c
Select Case Trim (CobMesMod. Text) 'depending on the type of message Text messages to choose read
Case 01 "#" 'humidity information
A=Right (STR, 4)
B=Mid (a, 1, 3)
C=Val (b)
TextHum. Text="c/10" + "%
"Case "02 #" 'temperature information
A=Right (STR, 4)
B=Mid (a, 1, 3)
C=Val (b)
TextTemp. Text="c/10 +"
Case "03 #" wet, temperature information
A=Right (STR, 8)
B=Mid (a, 1, 3)
C=Val (b)
TextHum. Text="c/10" + "%
"A, b=Mid (5, 3)
C=Val (b)
TextTemp. Text="c/10 +"
End the Select
End Sub
CodePudding user response:
Form2.Com m1. The Output="AT + CMGS=" + Trim (TxtID. Text) + CRH (13) + CRH (10)