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

📄 form1.frm

📁 VB下的串口发短信程序,可选择端口
💻 FRM
字号:
VERSION 5.00
Object = "{C330114C-8968-4469-83D1-736DE1640031}#13.2#0"; "alasunsmscon.ocx"
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "深圳蓝天信息技术短信控件使用示例(VB版)"
   ClientHeight    =   8610
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   10830
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   8610
   ScaleWidth      =   10830
   StartUpPosition =   3  '窗口缺省
   Begin alasun.alasunsms alasunsms1 
      Left            =   8040
      Top             =   600
      _ExtentX        =   979
      _ExtentY        =   979
   End
   Begin VB.Frame Frame4 
      Caption         =   "读短信"
      Height          =   1725
      Left            =   150
      TabIndex        =   3
      Top             =   4680
      Width           =   8655
      Begin VB.TextBox txtReadCon 
         Height          =   915
         Left            =   4200
         MultiLine       =   -1  'True
         TabIndex        =   24
         Top             =   750
         Width           =   4215
      End
      Begin VB.TextBox txtSendTime 
         Height          =   315
         Left            =   1170
         TabIndex        =   23
         Top             =   1200
         Width           =   1845
      End
      Begin VB.CommandButton cmdRead 
         Caption         =   "读短信"
         Enabled         =   0   'False
         Height          =   435
         Left            =   3150
         TabIndex        =   20
         Top             =   210
         Width           =   1305
      End
      Begin VB.TextBox txtFromNo 
         Height          =   315
         Left            =   1200
         TabIndex        =   19
         Top             =   780
         Width           =   1785
      End
      Begin VB.TextBox txtIndex 
         Height          =   315
         Left            =   1230
         TabIndex        =   17
         Top             =   330
         Width           =   645
      End
      Begin VB.Label Label7 
         AutoSize        =   -1  'True
         Caption         =   "短信内容:"
         Height          =   195
         Left            =   3240
         TabIndex        =   25
         Top             =   840
         Width           =   900
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "发送时间:"
         Height          =   195
         Left            =   180
         TabIndex        =   22
         Top             =   1200
         Width           =   900
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "来自号码:"
         Height          =   195
         Left            =   180
         TabIndex        =   21
         Top             =   780
         Width           =   900
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "条短信"
         Height          =   195
         Left            =   1980
         TabIndex        =   18
         Top             =   390
         Width           =   540
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "我要读出第"
         Height          =   195
         Left            =   180
         TabIndex        =   16
         Top             =   390
         Width           =   900
      End
   End
   Begin VB.Frame Frame3 
      Caption         =   "接收短信"
      Height          =   3105
      Left            =   4920
      TabIndex        =   2
      Top             =   1470
      Width           =   3855
      Begin VB.TextBox txtReceive 
         Height          =   2445
         Left            =   180
         MultiLine       =   -1  'True
         TabIndex        =   15
         Top             =   390
         Width           =   3465
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "发送短信"
      Height          =   3105
      Left            =   180
      TabIndex        =   1
      Top             =   1500
      Width           =   4575
      Begin VB.CommandButton cmdSend 
         Caption         =   "发送"
         Enabled         =   0   'False
         Height          =   405
         Left            =   3120
         TabIndex        =   14
         Top             =   2550
         Width           =   1215
      End
      Begin VB.CheckBox chkFlash 
         Caption         =   "免提"
         Height          =   345
         Left            =   2130
         TabIndex        =   13
         Top             =   2490
         Width           =   765
      End
      Begin VB.CheckBox chkBlink 
         Caption         =   "闪烁"
         Height          =   285
         Left            =   1260
         TabIndex        =   12
         Top             =   2520
         Width           =   705
      End
      Begin VB.TextBox txtCon 
         Height          =   1275
         Left            =   1260
         MultiLine       =   -1  'True
         TabIndex        =   11
         Top             =   840
         Width           =   2805
      End
      Begin VB.TextBox txtNo 
         Height          =   405
         Left            =   1260
         TabIndex        =   10
         Top             =   360
         Width           =   2775
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         Caption         =   "短信内容:"
         Height          =   195
         Left            =   330
         TabIndex        =   26
         Top             =   930
         Width           =   900
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "手机号码:"
         Height          =   195
         Left            =   330
         TabIndex        =   9
         Top             =   450
         Width           =   900
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "短信设备连接"
      Height          =   1185
      Left            =   180
      TabIndex        =   0
      Top             =   180
      Width           =   8625
      Begin VB.CommandButton cmdDisConnect 
         Caption         =   "断开"
         Enabled         =   0   'False
         Height          =   405
         Left            =   6570
         TabIndex        =   8
         Top             =   420
         Width           =   1065
      End
      Begin VB.CommandButton cmdConnect 
         Caption         =   "连接"
         Height          =   405
         Left            =   5190
         TabIndex        =   7
         Top             =   420
         Width           =   975
      End
      Begin VB.TextBox txtCommPort 
         Height          =   405
         Left            =   3990
         TabIndex        =   6
         Text            =   "1"
         Top             =   420
         Width           =   855
      End
      Begin VB.TextBox txtMsgCenter 
         Height          =   405
         Left            =   1440
         TabIndex        =   5
         Text            =   "+8613800280500"
         Top             =   420
         Width           =   2175
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "短信中心号码:"
         Height          =   195
         Left            =   210
         TabIndex        =   4
         Top             =   510
         Width           =   1260
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'=================================
'本程序展示了蓝天信息技术短信控件的核心功能
'
'================================

Private Sub alasunsms1_OnReceive()
    Dim sNo As String, sCon As String, sMsgCenterNo As String
    Dim dSendTime As Date, lTimeZone As Integer
    If alasunsms1.ReadMsg(sNo, sCon, sMsgCenterNo, dSendTime, lTimeZone) = 0 Then
        txtReceive.Text = dSendTime & "收到来自" & sNo & "的短信,短信中心号:" & sMsgCenterNo & "内容:" & sCon
    End If
End Sub

Private Sub cmdConnect_Click()
    alasunsms1.CommPort = Val(txtCommPort.Text)
    If alasunsms1.OpenComm() = 0 Then
        alasunsms1.SetMsgCenterNo txtMsgCenter.Text
        cmdConnect.Enabled = False
        cmdDisConnect.Enabled = True
        cmdSend.Enabled = True
        cmdRead.Enabled = True
        MsgBox "设备打开成功"
    Else
        MsgBox "设备打开失败"
    End If
End Sub


Private Sub cmdDisConnect_Click()
   If alasunsms1.CloseComm = 0 Then
    cmdConnect.Enabled = True
    cmdDisConnect.Enabled = False
    cmdSend.Enabled = False
    cmdRead.Enabled = False
    MsgBox "设备关闭成功"
  Else
    MsgBox "设备关闭失败"
  End If
End Sub

Private Sub cmdRead_Click()
    Dim sNo As String, sCon As String, sMsgCenterNo As String
    Dim dSendTime As Date, lTimeZone As Integer
    If alasunsms1.ReadMsgByIndex(CInt(txtIndex.Text), sNo, sCon, sMsgCenterNo, dSendTime, lTimeZone) = 0 Then
        txtFromNo.Text = sNo
        txtSendTime.Text = dSendTime
        txtReadCon.Text = sCon
    End If
End Sub

Private Sub cmdSend_Click()
    Dim lngMsgType As Long
    If chkBlink.Value = 1 Then
        lngMsgType = lngMsgType + alasunBlinking
    End If
    If chkFlash.Value = 1 Then
        lngMsgType = lngMsgType + alasunFlash
    End If
    If alasunsms1.SendMsg(txtNo.Text, txtCon.Text, , lngMsgType) = 0 Then
        MsgBox "发送成功"
    Else
        MsgBox "发送失败"
    End If
End Sub

⌨️ 快捷键说明

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