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

📄 form2.frm

📁 电子皮带秤数据采集工具
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "mscomm32.ocx"
Begin VB.Form Form1 
   BackColor       =   &H00C0C0C0&
   Caption         =   "Form1"
   ClientHeight    =   1920
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5490
   FillColor       =   &H000000FF&
   ForeColor       =   &H00C00000&
   LinkTopic       =   "Form1"
   ScaleHeight     =   1920
   ScaleWidth      =   5490
   StartUpPosition =   3  '窗口缺省
   WindowState     =   1  'Minimized
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   400
      Left            =   1200
      Top             =   360
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   240
      Top             =   240
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
      RThreshold      =   90
      ParitySetting   =   4
      InputMode       =   1
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim pp As Variant
Dim j
Dim i As Integer
Dim yy
Private Sub Command1_Click()
MSComm1.PortOpen = True
Timer1.Enabled = True

End Sub

Private Sub Command4_Click()
  End

End Sub

Private Sub MSComm1_OnComm()
'On Error Resume Next
Dim pp As Variant
Dim nn As Variant
Dim i As Integer

pp = MSComm1.Input


      If pp(15) > 127 Then
               C = -1
               pp(15) = pp(15) - 128
            Else
               C = 1
            End If
            a = pp(15) * 256 ^ 3 + pp(14) * 256 ^ 2 + pp(13) * 256 + pp(12)
            b = (pp(11) * 256 + pp(10)) / 65536
            
         If pp(2) > 127 Then
               C1 = -1
               pp(2) = pp(2) - 128   ' 原码
            Else
               C1 = 1
            End If
            '   阶码符号
           If pp(3) > 127 Then
               b1 = pp(3) - 256 '补码
            Else
               b1 = pp(3)
            End If
          f1 = pp(2) * 256 ^ 2 + pp(1) * 256 + pp(0)
            g1 = f1 * 2 ^ (b1 - 23) * C1
           
          '皮带速度处理
             If pp(82) > 127 Then
               C2 = -1
               pp(82) = pp(82) - 128   ' 原码
           Else
               C2 = 1
            End If
            '   阶码符号
           If pp(83) > 127 Then
               b2 = pp(83) - 256  '补码
            Else
               b2 = pp(83)
            End If
            a2 = pp(82) * 256 ^ 2 + pp(81) * 256 + pp(80)
            a2 = a2 * 2 ^ (b2 - 23) * C2
            
            
           

       If pp(90) = 1 Then
               
              TT.Text1 = Format(CDbl(g1), "#0.000")
               TT.Text2 = Format(CDbl(a) + CDbl(b), "#0.000")
               
             'l1(1) = Format(CDbl(g1), "#0.000") '显示仪表流量
           'l1(0) = Format(CDbl(a) + CDbl(b), "#0.000") '显示仪表累计值
          'l1(2) = Format(CDbl(a), "#0.000") '显示皮带速度
         End If
           If pp(90) = 2 Then
           
           TT.Text3 = Format(CDbl(g1), "#0.000")
           TT.Text4 = Format(CDbl(a) + CDbl(b), "#0.000")
           
           ' l2(1) = Format(CDbl(g1), "#0.000") '显示仪表流量
           'l2(0) = Format(CDbl(a) + CDbl(b), "#0.000") '显示仪表累计值
            'l2(2) = Format(CDbl(a), "#0.000") '显示皮带速度
         End If
           If pp(90) = 3 Then
           
           TT.Text5 = Format(CDbl(g1), "#0.000")
           TT.Text6 = Format(CDbl(a) + CDbl(b), "#0.000")
         '
            ' l3(1) = Format(CDbl(g1), "#0.000") '显示仪表流量
          ' l3(0) = Format(CDbl(a) + CDbl(b), "#0.000") '显示仪表累计值
           ' l3(2) = Format(CDbl(a), "#0.00") '显示皮带速度
         End If
           If pp(90) = 4 Then
           TT.Text7 = Format(CDbl(g1), "#0.000")
           TT.Text8 = Format(CDbl(a) + CDbl(b), "#0.000")
            ' l9(1) = Format(CDbl(g1), "#0.000") '显示仪表流量
           'l9(0) = Format(CDbl(a) + CDbl(b), "#0.000") '显示仪表累计值
            'l9(2) = Format(CDbl(a), "#0.000") '显示皮带速度
           
           End If
           
           If pp(90) = 5 Then
           TT.Text9 = Format(CDbl(g1), "#0.000")
           TT.Text10 = Format(CDbl(a) + CDbl(b), "#0.000")
            ' l9(1) = Format(CDbl(g1), "#0.000") '显示仪表流量
           'l9(0) = Format(CDbl(a) + CDbl(b), "#0.000") '显示仪表累计值
            'l9(2) = Format(CDbl(a), "#0.000") '显示皮带速度
           End If
           
           If pp(90) = 6 Then
           TT.Text11 = Format(CDbl(g1), "#0.000")
           TT.Text12 = Format(CDbl(a) + CDbl(b), "#0.000")
            ' l9(1) = Format(CDbl(g1), "#0.000") '显示仪表流量
           'l9(0) = Format(CDbl(a) + CDbl(b), "#0.000") '显示仪表累计值
            'l9(2) = Format(CDbl(a), "#0.000") '显示皮带速度
           
         End If
    

End Sub

Private Sub Timer1_Timer()
 
gjn1
TimeDelay 300

gjn2
TimeDelay 300

gjn3
TimeDelay 300

gjn4
TimeDelay 300

gjn5
TimeDelay 300

gjn6

End Sub

Public Sub gjn1()

j = MSComm1.Input
Dim a(6) As Byte
Dim b(0) As Byte
Dim t1, t2
b(0) = 1
MSComm1.Settings = "9600,n,8,1"
MSComm1.Output = b
TimeDelay 10
Dim inputbyte(6) As Byte
     inputbyte(0) = 2
     inputbyte(1) = 0
     inputbyte(2) = 0
     inputbyte(3) = 0
     inputbyte(4) = 0
     inputbyte(5) = 0
     inputbyte(6) = (1 + 2) Mod 256
 MSComm1.Settings = "9600,s,8,1"
 MSComm1.Output = inputbyte

End Sub

Public Sub gjn2()

j = MSComm1.Input
Dim a(6) As Byte
Dim b(0) As Byte
Dim t1, t2
b(0) = 2
MSComm1.Settings = "9600,n,8,1"
MSComm1.Output = b
TimeDelay 10
Dim inputbyte(6) As Byte
     inputbyte(0) = 2
     inputbyte(1) = 0
     inputbyte(2) = 0
     inputbyte(3) = 0
     inputbyte(4) = 0
     inputbyte(5) = 0
     inputbyte(6) = (2 + 2) Mod 256
 MSComm1.Settings = "9600,s,8,1"
 MSComm1.Output = inputbyte
End Sub

Public Sub gjn3()
j = MSComm1.Input
Dim a(6) As Byte
Dim b(0) As Byte
Dim t1, t2
b(0) = 3
MSComm1.Settings = "9600,n,8,1"
MSComm1.Output = b
TimeDelay 10
Dim inputbyte(6) As Byte
     inputbyte(0) = 2
     inputbyte(1) = 0
     inputbyte(2) = 0
     inputbyte(3) = 0
     inputbyte(4) = 0
     inputbyte(5) = 0
     inputbyte(6) = (3 + 2) Mod 256
 MSComm1.Settings = "9600,s,8,1"
 MSComm1.Output = inputbyte
End Sub

Public Sub gjn4()
j = MSComm1.Input
Dim a(6) As Byte
Dim b(0) As Byte
Dim t1, t2
b(0) = 4
MSComm1.Settings = "9600,n,8,1"
MSComm1.Output = b
TimeDelay 10
Dim inputbyte(6) As Byte
     inputbyte(0) = 2
     inputbyte(1) = 0
     inputbyte(2) = 0
     inputbyte(3) = 0
     inputbyte(4) = 0
     inputbyte(5) = 0
     inputbyte(6) = (4 + 2) Mod 256
 MSComm1.Settings = "9600,s,8,1"
 MSComm1.Output = inputbyte
 End Sub
Public Sub gjn5()
j = MSComm1.Input
Dim a(6) As Byte
Dim b(0) As Byte
Dim t1, t2
b(0) = 5
MSComm1.Settings = "9600,n,8,1"
MSComm1.Output = b
TimeDelay 10
Dim inputbyte(6) As Byte
     inputbyte(0) = 2
     inputbyte(1) = 0
     inputbyte(2) = 0
     inputbyte(3) = 0
     inputbyte(4) = 0
     inputbyte(5) = 0
     inputbyte(6) = (5 + 2) Mod 256
 MSComm1.Settings = "9600,s,8,1"
 MSComm1.Output = inputbyte
 End Sub
Public Sub gjn6()
j = MSComm1.Input
Dim a(6) As Byte
Dim b(0) As Byte
Dim t1, t2
b(0) = 6
MSComm1.Settings = "9600,n,8,1"
MSComm1.Output = b
TimeDelay 10
Dim inputbyte(6) As Byte
     inputbyte(0) = 2
     inputbyte(1) = 0
     inputbyte(2) = 0
     inputbyte(3) = 0
     inputbyte(4) = 0
     inputbyte(5) = 0
     inputbyte(6) = (6 + 2) Mod 256
 MSComm1.Settings = "9600,s,8,1"
 MSComm1.Output = inputbyte
 End Sub

⌨️ 快捷键说明

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