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

📄 frmgb.frm

📁 这是一个基于金蝶K/3的磅秤插件源代码。安装本差价需要金蝶K/310.0以上的版本。本插件是客户端程序。在车辆过磅时自动产生金蝶K/3的出库单。
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Frmgb 
   Appearance      =   0  'Flat
   BorderStyle     =   1  'Fixed Single
   Caption         =   "过磅重量"
   ClientHeight    =   2085
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5775
   Icon            =   "Frmgb.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2085
   ScaleWidth      =   5775
   StartUpPosition =   1  '所有者中心
   Visible         =   0   'False
   Begin VB.Timer Timer2 
      Enabled         =   0   'False
      Interval        =   100
      Left            =   120
      Top             =   900
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   200
      Left            =   120
      Top             =   1500
   End
   Begin VB.CommandButton CmdCancel 
      Caption         =   "取消"
      Height          =   405
      Left            =   4260
      TabIndex        =   2
      Top             =   1500
      Width           =   1335
   End
   Begin VB.CommandButton CmdOk 
      Caption         =   "确定"
      Enabled         =   0   'False
      Height          =   405
      Left            =   2610
      TabIndex        =   1
      Top             =   1500
      Width           =   1395
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   0
      Top             =   1440
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      CommPort        =   2
      DTREnable       =   -1  'True
      OutBufferSize   =   1024
      RThreshold      =   1
      InputMode       =   1
   End
   Begin VB.Label Label3 
      Caption         =   "sss"
      Height          =   375
      Left            =   1140
      TabIndex        =   5
      Top             =   1500
      Visible         =   0   'False
      Width           =   795
   End
   Begin VB.Image ImgOff 
      Height          =   240
      Left            =   1110
      Picture         =   "Frmgb.frx":038A
      Stretch         =   -1  'True
      Top             =   60
      Width           =   240
   End
   Begin VB.Image ImgOn 
      Height          =   240
      Left            =   1110
      Picture         =   "Frmgb.frx":07CC
      Stretch         =   -1  'True
      Top             =   60
      Width           =   240
   End
   Begin VB.Label Label2 
      Caption         =   "重量"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   26.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   555
      Left            =   0
      TabIndex        =   4
      Top             =   90
      Width           =   1095
   End
   Begin VB.Label Label1 
      Caption         =   "Kg"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   26.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   555
      Left            =   450
      TabIndex        =   3
      Top             =   690
      Width           =   615
   End
   Begin VB.Label LabZL 
      Alignment       =   1  'Right Justify
      BackColor       =   &H80000007&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "00000000"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   48
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0000FFFF&
      Height          =   1245
      Left            =   1110
      TabIndex        =   0
      Top             =   60
      Width           =   4485
   End
End
Attribute VB_Name = "Frmgb"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
''''''''''''''''''''''''''''''''''''''''
'功能:通过串口读取电子磅秤的实际数据,并填入相应的K/3收料单表中
'
'
'编写:崔锐
'
'日期:2005-10-10
'
''''''''''''''''''''''''''''''''''''''''''

Option Explicit
Dim Out(18) As Byte   '接收var中的值
Dim var As Variant   '接收mscomm1.input中的数值
Dim bEnd As Boolean
Dim SjZl1 As String
Dim BeginTime As Date


Private Sub CmdCancel_Click()
    Timer2.Enabled = True
    SjZl = "-1"
End Sub


Private Sub OpenMsComm()

  On Error GoTo Err
    With MSComm1
        .InBufferCount = 0  '清除接收缓冲区
        .RThreshold = 1  '设置接收一个字节就产生OnComm事件
        
        If Not .PortOpen Then
            .InputMode = comInputModeBinary '设置数据接收模式为二进制形式

            .InBufferSize = 40         '设置缓冲区接收数据为40字节
    
            .InputLen = 1  '设置Input一次从接收缓冲读取字节数为1
    
            .PortOpen = True   '打开通信端口
    '        Lab3.Caption = "串口正常!"
            ImgOn.Visible = True
            ImgOff.Visible = False
        End If

    End With
    Exit Sub
Err:
    ImgOff.Visible = True
    ImgOn.Visible = False
    Timer1.Enabled = False
    bEnd = True
End Sub


Private Sub SwichVar(ByVal nNum As Integer)
    var = Null
    var = MSComm1.Input
    Out(nNum) = var(0)
  
End Sub

Private Sub CmdOK_Click()
    Timer2.Enabled = True
    SjZl = CStr(Val(LabZL.Caption) / 1000)
   
End Sub

Private Sub Form_Load()
'设置mscomm的相关参数
    On Error Resume Next
    MSComm1.CommPort = CInt(strPort)
    MSComm1.Settings = strSetting
    bEnd = True
    SjZl = "0"
    BeginTime = Now
    Timer1.Enabled = True
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If UnloadMode = 0 Then Cancel = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
    If MSComm1.PortOpen Then
        MSComm1.PortOpen = False   '关闭通信端口
    End If
End Sub

Private Sub MSComm1_OnComm()
Dim I As Integer
On Error GoTo Err
    With MSComm1
        Select Case .CommEvent  '判断通信事件

            Case comEvReceive:  '收到Rthreshold个字节产生的接收事件

                SwichVar 1


                If Out(1) = 2 Then   '判断是否为数据的开始标志&02H
                    bEnd = False
                    Label3.Caption = "begin"
                    .RThreshold = 0   '关闭OnComm事件接收
                
                    Do
    
                        DoEvents

                    Loop Until .InBufferCount >= 18  '循环等待接收缓冲区>=18个字节


                    For I = 2 To 18
                       
                        SwichVar I
    
                    Next

                
                    If Out(17) <> 13 Then  '判断接收数据的第17个字节是否为&0DH
                       .RThreshold = 1
                       
                    Else
                       
        '                  .PortOpen = False
                          '接收到的数据第5到10个字节为所需重量数据
                          SjZl = Chr(Out(5)) & Chr(Out(6)) & Chr(Out(7)) & Chr(Out(8)) & Chr(Out(9)) & Chr(Out(10))
                          '转换重量单位为吨
                          SjZl = Trim(Str(Val(SjZl) / 1000))
                          If SjZl1 <> SjZl Then
                               SjZl1 = SjZl
                               BeginTime = Now
                          End If
                    End If
                    bEnd = True
                    Label3.Caption = "end"
               End If
            Case Else
                bEnd = True
                Label3.Caption = "else"
        End Select

    End With
    Exit Sub
Err:
    If MSComm1.PortOpen Then MSComm1.PortOpen = False
    bEnd = True
End Sub

Private Sub Timer1_Timer()
Dim timediff As Integer
    If Not bEnd Then Exit Sub
    OpenMsComm
    LabZL.Caption = CStr(Val(SjZl) * 1000)
    If SjZl1 <> SjZl Or SjZl = "0" Then
        timediff = 0
    Else
        timediff = DateDiff("S", BeginTime, Now)
    End If
    If timediff > Val(strGBWDSJ) Then
        CmdOK.Enabled = True
    Else
        CmdOK.Enabled = False
    End If
End Sub

Private Sub Timer2_Timer()
    Timer1.Enabled = False
    If bEnd Then
        Unload Me
    End If
End Sub

⌨️ 快捷键说明

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