⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 design about GSM model sended and received communication appliance
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   7530
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   8775
   LinkTopic       =   "Form1"
   ScaleHeight     =   7530
   ScaleWidth      =   8775
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command6 
      Caption         =   "发送AT+CMGS"
      Height          =   375
      Left            =   960
      TabIndex        =   7
      Top             =   5400
      Width           =   1695
   End
   Begin VB.CommandButton Command5 
      Caption         =   "发送AT+CSCA"
      Height          =   495
      Left            =   960
      TabIndex        =   6
      Top             =   4680
      Width           =   1695
   End
   Begin VB.CommandButton Command4 
      Caption         =   "发送AT+CMGF"
      Height          =   375
      Left            =   960
      TabIndex        =   5
      Top             =   4200
      Width           =   1695
   End
   Begin VB.CommandButton Command3 
      Caption         =   "发送AT命令 "
      Height          =   495
      Left            =   960
      TabIndex        =   4
      Top             =   3600
      Width           =   1695
   End
   Begin VB.CommandButton Command2 
      Caption         =   "打开串口"
      Height          =   375
      Left            =   5400
      TabIndex        =   3
      Top             =   1080
      Width           =   1815
   End
   Begin VB.ComboBox Combo1 
      Height          =   300
      Left            =   1800
      TabIndex        =   2
      Top             =   1080
      Width           =   2535
   End
   Begin VB.CommandButton Command1 
      Caption         =   "发送test"
      Height          =   495
      Left            =   960
      TabIndex        =   1
      Top             =   6000
      Width           =   1695
   End
   Begin VB.ListBox List1 
      Appearance      =   0  'Flat
      Height          =   1650
      Left            =   480
      TabIndex        =   0
      Top             =   1680
      Width           =   7695
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   840
      Top             =   480
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
   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()


            MSComm1.RThreshold = 1
            MSComm1.SThreshold = 1
            MSComm1.Settings = "9600,n,8,1"
            MSComm1.OutBufferCount = 0
            MSComm1.InBufferCount = 0
            MSComm1.InputMode = comInputModeBinary

  MSComm1.Output = "test" & Chr$(26)  'chr$(26)是Ctr+ Z
            
End Sub

Private Sub Command2_Click()
Dim i As Integer
Dim str As String
On Error Resume Next
str = Mid((Combo1.Text), 4, 1)
i = Val(str)
  
MSComm1.CommPort = i
MSComm1.PortOpen = True
 
 List1.AddItem MSComm1.PortOpen
If MSComm1.PortOpen = False Then
 
   MsgBox "打开串口失败!", 0, "提示"
 
End If
End Sub
 
Private Sub Command3_Click()
            MSComm1.RThreshold = 1
            MSComm1.SThreshold = 1
            MSComm1.Settings = "9600,n,8,1"
            MSComm1.OutBufferCount = 0
            MSComm1.InBufferCount = 0
            MSComm1.InputMode = comInputModeBinary
 
            
            MSComm1.Output = "AT" + vbCr
 
End Sub

Private Sub Command4_Click()
            MSComm1.RThreshold = 1
            MSComm1.SThreshold = 1
            MSComm1.Settings = "9600,n,8,1"
            MSComm1.OutBufferCount = 0
            MSComm1.InBufferCount = 0
            MSComm1.InputMode = comInputModeBinary
 
 MSComm1.Output = "AT+CMGF=1" + vbCr
 
 
End Sub

Private Sub Command5_Click()
            MSComm1.RThreshold = 1
            MSComm1.SThreshold = 1
            MSComm1.Settings = "9600,n,8,1"
            MSComm1.OutBufferCount = 0
            MSComm1.InBufferCount = 0
            MSComm1.InputMode = comInputModeBinary
MSComm1.Output = "AT+CSCA=" & Chr$(34) & "短消息中心地址 " & Chr$(34) & ",129" + vbCr '短消息中心地址 比如开封的为 8613800378500,这里为(MSComm1.Output = "AT+CSCA=" & Chr$(34) & "8613800378500 " & Chr$(34) & ",129" + vbCr)地区不同号码也不同,可上网查询

End Sub

Private Sub Command6_Click()

            MSComm1.RThreshold = 1
            MSComm1.SThreshold = 1
            MSComm1.Settings = "9600,n,8,1"
            MSComm1.OutBufferCount = 0
            MSComm1.InBufferCount = 0
            MSComm1.InputMode = comInputModeBinary
   MSComm1.Output = "AT+CMGS=" & Chr$(34) & "目的手机号码" & Chr$(34) & ",129" + vbCr  '其中目的手机号码写入要发送的手机号,比如手机号码134xxxxxxxx 语句为  MSComm1.Output = "AT+CMGS=" & Chr$(34) & "134xxxxxxxx" & Chr$(34) & ",129" + vbCr
End Sub

 

Private Sub Form_Load()
 On Error Resume Next
Dim i As Integer
For i = 1 To 10

    MSComm1.CommPort = i
    MSComm1.PortOpen = True

    If MSComm1.PortOpen = False Then

       GoTo 20
    Else
      Combo1.AddItem ("com" & i)
'      c = i
      MSComm1.PortOpen = False

    End If
20

Next i

 
MSComm1.RThreshold = 1
MSComm1.SThreshold = 1
MSComm1.Settings = "9600,n,8,1"
MSComm1.OutBufferCount = 0              '清空发送缓冲区
MSComm1.InBufferCount = 0 '清空接收缓冲区
'MSComm1.InputMode = comInputModeBinary '设置接收数据模式为字符文本模式

End Sub
''
Private Sub MSComm1_OnComm()
Dim abuffer() As Byte
 Dim i As Integer

Dim buf As String

' Sleep 500
 If MSComm1.InBufferCount > 0 Then

       abuffer = MSComm1.Input

       buf = ""
      For i = LBound(abuffer) To UBound(abuffer)

         buf = buf + Hex(abuffer(i)) + Chr(32)
     '    inbyte1(i) = abuffer(i)
      Next i

    List1.AddItem ""
    List1.AddItem buf


 End If
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -