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

📄 form1.frm

📁 地磅的程序及图纸
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   2520
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   10.5
      Charset         =   134
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   ScaleHeight     =   2520
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.ComboBox Combo1 
      CausesValidation=   0   'False
      Height          =   330
      ItemData        =   "Form1.frx":0000
      Left            =   2880
      List            =   "Form1.frx":000A
      TabIndex        =   5
      Text            =   "显示"
      Top             =   240
      Width           =   1215
   End
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   18
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   600
      MaxLength       =   9
      TabIndex        =   0
      Text            =   "012345671"
      Top             =   1560
      Width           =   2100
   End
   Begin VB.CommandButton Command2 
      Caption         =   "二号屏发送"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2880
      TabIndex        =   3
      Top             =   1680
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "一号屏发送"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2880
      TabIndex        =   2
      Top             =   840
      Width           =   1215
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   18
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   600
      MaxLength       =   9
      TabIndex        =   1
      Text            =   "012345671"
      Top             =   720
      Width           =   2055
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   120
      Top             =   120
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
   End
   Begin VB.Label Label1 
      Caption         =   "屏幕显示状态:"
      BeginProperty Font 
         Name            =   "MS Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   960
      TabIndex        =   4
      Top             =   240
      Width           =   1815
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim commandreceive As String
Dim commandsend As String
Dim commandreset As String
Dim strdispid As String
Dim strdatasend As String
Dim strreceive As String

Private Sub Command1_Click()

MSComm1.InBufferCount = 0 '清除发送缓冲区数据
MSComm1.OutBufferCount = 0 '清除接收缓冲区数据

If Combo1.Text = "显示" Then
    commandreset = "1"
Else
    commandreset = "0"
End If
'commandreceive = "55"   ' 55H: 要求大屏幕接收数据
'commandreset = "ff"     'FFH   大屏幕复位,重新接收地址
strdispid = "e01"        '两位地址位

strdadasend = Text1.Text
'strdispid = Left(strdadasend, 2)  '取两位地址位
'MSComm1.Output = commandreset '大屏幕复位,重新接收地址
'MSComm1.Output = commandreceive '要求大屏幕接收数据
MSComm1.Output = strdispid        '向COM1发送地址
MSComm1.Output = strdadasend  '如果相同则发送数据
MSComm1.Output = commandreset '大屏幕复位,重新接收地址
            
End Sub

Private Sub Command2_Click()

MSComm1.InBufferCount = 0 '清除发送缓冲区数据
MSComm1.OutBufferCount = 0 '清除接收缓冲区数据

If Combo1.Text = "显示" Then
    commandreset = "1"
Else
    commandreset = "0"
End If
'commandreceive = "55"   ' 55H: 要求大屏幕接收数据
'commandreset = "ff"     'FFH   大屏幕复位,重新接收地址
strdispid = "e02"        '两位地址位

strdadasend = Text2.Text
'strdispid = Left(strdadasend, 2)  '取两位地址位
'MSComm1.Output = commandreceive '要求大屏幕接收数据
MSComm1.Output = strdispid        '向COM1发送地址
MSComm1.Output = strdadasend  '如果相同则发送数据
MSComm1.Output = commandreset '大屏幕复位,重新接收地址

End Sub

Private Sub Form_Load()

MSComm1.InBufferCount = 0 '清除发送缓冲区数据
MSComm1.OutBufferCount = 0 '清除接收缓冲区数据

commandsend = "aa"      'AAH:  要求大屏幕发送数据
commandreset = "1"

MSComm1.CommPort = 1            ' 选择COM口1
MSComm1.Settings = "9600,N,8,1" '波特率为9600,无奇偶校验,8位数据位,一位停止位
MSComm1.PortOpen = True       ' 打开串行口
MSComm1.InputLen = 0          '读取整个接收缓冲区内码或消除
'MSComm1.Output = commandreset '大屏幕复位,重新接收地址
'MSComm1.Output = commandreceive '要求大屏幕接收数据



End Sub


Private Sub MSComm1_OnComm()

Select Case MSComm1.CommEvent
            
    Case comEvReceive
    
        strreceive = MSComm1.Input '从COM接收地址
        'Text2.Text = strreceive    '显示接收的数据
        
         If strdispid = strreceive Then
            MSComm1.Output = strdadasend  '如果相同则发送数据
           Else: MSComm1.Output = commandreset '不相同则复位
           
         End If
 
End Select
End Sub

⌨️ 快捷键说明

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