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

📄 form2.frm

📁 GSM的VB实现代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form2 
   Caption         =   "Form2"
   ClientHeight    =   5010
   ClientLeft      =   5220
   ClientTop       =   2580
   ClientWidth     =   5235
   LinkTopic       =   "Form2"
   ScaleHeight     =   5010
   ScaleWidth      =   5235
   Begin VB.CommandButton Command2 
      Caption         =   "Cancel"
      Height          =   375
      Left            =   2760
      TabIndex        =   15
      Top             =   4440
      Width           =   1575
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Ok"
      Height          =   375
      Left            =   600
      TabIndex        =   14
      Top             =   4440
      Width           =   1455
   End
   Begin VB.ComboBox Combo6 
      Height          =   315
      ItemData        =   "Form2.frx":0000
      Left            =   2880
      List            =   "Form2.frx":0010
      TabIndex        =   13
      Text            =   "3"
      Top             =   840
      Width           =   1695
   End
   Begin VB.ComboBox Combo5 
      Height          =   315
      ItemData        =   "Form2.frx":0020
      Left            =   2880
      List            =   "Form2.frx":002A
      TabIndex        =   11
      Text            =   "0"
      Top             =   3600
      Width           =   1695
   End
   Begin VB.ComboBox Combo4 
      Height          =   315
      ItemData        =   "Form2.frx":0034
      Left            =   2880
      List            =   "Form2.frx":0041
      TabIndex        =   9
      Text            =   "1"
      Top             =   3120
      Width           =   1695
   End
   Begin VB.ComboBox Combo3 
      Height          =   315
      ItemData        =   "Form2.frx":0050
      Left            =   2880
      List            =   "Form2.frx":0057
      TabIndex        =   7
      Text            =   "N"
      Top             =   2520
      Width           =   1695
   End
   Begin VB.ComboBox Combo2 
      Height          =   315
      ItemData        =   "Form2.frx":005E
      Left            =   2880
      List            =   "Form2.frx":006E
      TabIndex        =   6
      Text            =   "8"
      Top             =   1920
      Width           =   1695
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   2880
      TabIndex        =   3
      Top             =   120
      Width           =   1575
   End
   Begin VB.ComboBox Combo1 
      Height          =   315
      ItemData        =   "Form2.frx":007E
      Left            =   2880
      List            =   "Form2.frx":0088
      TabIndex        =   1
      Text            =   "9600"
      Top             =   1320
      Width           =   1695
   End
   Begin VB.Label Label7 
      Caption         =   "interface"
      Height          =   375
      Left            =   600
      TabIndex        =   12
      Top             =   720
      Width           =   1575
   End
   Begin VB.Label Label6 
      Caption         =   "Flow control"
      Height          =   375
      Left            =   600
      TabIndex        =   10
      Top             =   3480
      Width           =   1575
   End
   Begin VB.Label Label5 
      Caption         =   "Stop bits"
      Height          =   255
      Left            =   600
      TabIndex        =   8
      Top             =   3000
      Width           =   1575
   End
   Begin VB.Label Label4 
      Caption         =   "Parity"
      Height          =   255
      Left            =   600
      TabIndex        =   5
      Top             =   2520
      Width           =   1575
   End
   Begin VB.Label Label3 
      Caption         =   "Data bits"
      Height          =   255
      Left            =   600
      TabIndex        =   4
      Top             =   2040
      Width           =   1575
   End
   Begin VB.Label Label2 
      Caption         =   "Bits per second"
      Height          =   375
      Left            =   600
      TabIndex        =   2
      Top             =   1320
      Width           =   1575
   End
   Begin VB.Label Label1 
      Caption         =   "Name"
      Height          =   375
      Left            =   600
      TabIndex        =   0
      Top             =   120
      Width           =   1575
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub ALL_DisAbled()
Form1.Command1.Enabled = False
Form1.Command2.Enabled = False
Form1.Command3.Enabled = False
Form1.Command4.Enabled = False
Form1.Command5.Enabled = False
Form1.Command6.Enabled = False
Form1.Command7.Enabled = False
Form1.Command8.Enabled = False
Form1.Command9.Enabled = False
Form1.Command10.Enabled = False
Form1.Command11.Enabled = False
End Sub

Private Sub ALL_EnAbled()
Form1.Command1.Enabled = True
Form1.Command2.Enabled = True
Form1.Command3.Enabled = True
Form1.Command4.Enabled = True
Form1.Command5.Enabled = True
Form1.Command6.Enabled = True
Form1.Command7.Enabled = True
Form1.Command8.Enabled = True
Form1.Command9.Enabled = True
Form1.Command10.Enabled = True
Form1.Command11.Enabled = True
End Sub

Private Sub Command1_Click()
If Form1.MSComm1.PortOpen = True Then
x = MsgBox("端口正在被使用,请关门其它程序后重试")
Form1.Label5.Caption = "状态:连接失败,端口正在被使用"
Call ALL_DisAbled
Else
Call ALL_EnAbled
Form1.MSComm1.CommPort = Int(Form2.Combo6.Text)   '选择端口1
Form1.MSComm1.Settings = Form2.Combo1.Text & "," & Form2.Combo3.Text & "," & Form2.Combo2.Text & "," & Form2.Combo4.Text 'MSComm控件属性设定
Call Form1.delay(1)
Form1.MSComm1.PortOpen = True

  If Form1.MSComm1.PortOpen = True Then '查看连接是否成功
     Form1.MSComm1.InBufferCount = 0 '清空接收缓冲区
    Form1.MSComm1.InputLen = 0 '一次读取接收缓冲区中的全部内容
    Form1.MSComm1.Output = "AT" + vbCr
   
Call Form1.delay(0.5)

     Form1.Label5.Caption = "状态:已连接"
  Else
     x = MsgBox("连接失败,请重试")
     Form1.Label5.Caption = "状态:连接失败,没有返回值"
     Call ALL_DisAbled
  End If
 
End If

 

Form1.Show

Unload Me


End Sub

Private Sub Form_Load()
Form2.Combo6.Text = Form1.MSComm1.CommPort
End Sub

⌨️ 快捷键说明

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