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

📄 frmmain.frm

📁 LCD SN 烧录 软件!可以烧录序列号
💻 FRM
📖 第 1 页 / 共 3 页
字号:
         Height          =   375
         Left            =   3840
         TabIndex        =   4
         Top             =   2520
         Width           =   855
      End
      Begin VB.CommandButton Cmdpause 
         Caption         =   "中断"
         Height          =   375
         Left            =   3840
         TabIndex        =   3
         Top             =   1560
         Width           =   855
      End
      Begin MSCommLib.MSComm MSComm1 
         Left            =   -360
         Top             =   3240
         _ExtentX        =   1005
         _ExtentY        =   1005
         _Version        =   393216
         DTREnable       =   -1  'True
      End
      Begin VB.Label Label9 
         AutoSize        =   -1  'True
         Caption         =   "Delay Time Setting"
         Height          =   195
         Left            =   -71880
         TabIndex        =   36
         Top             =   600
         Width           =   1335
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         Caption         =   "发送SN:"
         Height          =   195
         Left            =   240
         TabIndex        =   34
         Top             =   720
         Width           =   765
      End
      Begin VB.Label Label4 
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   1695
         Left            =   720
         TabIndex        =   25
         Top             =   1320
         Width           =   2895
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "串口状态"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   240
         Left            =   1680
         TabIndex        =   10
         Top             =   1050
         Width           =   780
      End
   End
   Begin VB.Label Label7 
      Caption         =   " 版本:V1.3         日 期:2006/02/23"
      Height          =   555
      Left            =   4200
      TabIndex        =   27
      Top             =   240
      Width           =   1605
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "ViewSonic 条码烧录"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   240
      Left            =   1440
      TabIndex        =   12
      Top             =   360
      Width           =   2370
   End
End
Attribute VB_Name = "FrmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'V1.0 Demo
'V1.1 增加英文支持
'2006-01-20 调试过程中出现副作用窗口
'V1.3 优化代码,修改烧录SN起始部分出现乱码,屏蔽烧录过程中弹出的测试窗口 2006-02-23
'待处理项:自动搜索COM口,DELAY方式切换查询方式,报错机制
Public bRun As Boolean

Public CurrentSettings As String
Public CurrentPort   As Integer

Public Delay_Time  As Long
Public RecycleNum, Delay_Times As Integer
Public PressEnterTime As Long

Public BarcodeLen, BarcodeStart, BarcodeEnd As Integer '条码总长度,条码有效初位,条码有效末位
Sub LoadLanguageSettings() 'Language Settings (Load all language and Set display current language)
CboLanguage.AddItem "Englsih"
CboLanguage.AddItem "Simple CHinese"

CboLanguage.ListIndex = 0
End Sub
Sub LoadPropertySettings()  'Serial Port Settings (Load all items and Display current item)
Dim i As Integer, Settings As String, Offset As Integer

'ComboBox Items Loading
For i = 1 To 8
    cboPort.AddItem "Com" & Trim$(str$(i))
Next i

cboSpeed.AddItem "4800"
cboSpeed.AddItem "9600"
cboSpeed.AddItem "14400"
cboSpeed.AddItem "19200"
cboSpeed.AddItem "28800"
cboSpeed.AddItem "38400"
cboSpeed.AddItem "56000"
cboSpeed.AddItem "57600"
cboSpeed.AddItem "115200"
cboSpeed.AddItem "128000"

cboDataBits.AddItem "4"
cboDataBits.AddItem "5"
cboDataBits.AddItem "6"
cboDataBits.AddItem "7"
cboDataBits.AddItem "8"

cboParity.AddItem "Even"
cboParity.AddItem "Odd"
cboParity.AddItem "None"
cboParity.AddItem "Mark"
cboParity.AddItem "Space"

cboStopBits.AddItem "1"
cboStopBits.AddItem "1.5"
cboStopBits.AddItem "2"

' Set Current ComboBox Item: Set ListIndex or Text accroding Settings such as 9600,n,8,1
Settings = CurrentSettings

If InStr(Settings, ".") > 0 Then  '9600,n,8,1 后三位基本固定,只有最后1位可能会出现1.5的情况,以“。”识别
    Offset = 2
Else
    Offset = 0
End If

cboPort.ListIndex = MSComm1.CommPort - 1  '  1-->COM 1
'cboPort.Text = "Com" & MSComm1.CommPort

cboSpeed.Text = Left$(Settings, Len(Settings) - 6 - Offset) '9600->9600

Select Case Mid$(Settings, Len(Settings) - 4 - Offset, 1) 'n->none
Case "e"
    cboParity.ListIndex = 0
Case "m"
    cboParity.ListIndex = 1
Case "n"
    cboParity.ListIndex = 2
Case "o"
    cboParity.ListIndex = 3
Case "s"
    cboParity.ListIndex = 4
End Select

cboDataBits.Text = Mid$(Settings, Len(Settings) - 2 - Offset, 1) '8->8
cboStopBits.Text = Right$(Settings, 1 + Offset)                  '1->1

End Sub
Private Sub CboLanguage_Click() 'Support more Language by jack 060116
Dim i, iSSTab As Integer

iSSTab = SSTab1.Tab

Select Case CboLanguage.ListIndex
Case 0
   Label3.Caption = "View Sonic SN Writer"
   Label7.Caption = "Ver:V1.3" & vbCrLf & "Date:2006/02/23"
   
   For i = 0 To SSTab1.Tabs - 1
     SSTab1.Tab = i
     If i = 0 Then
          SSTab1.Caption = "SN Writer"
       ElseIf i = 1 Then
          SSTab1.Caption = "Port Setting"
       ElseIf i = 2 Then
          SSTab1.Caption = "Other Setting"
     End If
    Next
    
            Label8.Caption = "SN "
            Label2.Caption = "Serial Port Status"
            CmdSend.Caption = "Send"
            Cmdpause.Caption = "Pause"
            CmdExit.Caption = "Exit"
          
            Label1(3).Caption = "Port Num."
            Label1(2).Caption = "Baud Speed"
            Label1(8).Caption = "Serial Port:"
            Label1(7).Caption = "Para.:"
            CmdOK.Caption = "OK"
            Frame2.Caption = "Para. Setting"
            Label1(6).Caption = "Data Bit:"
            Label1(5).Caption = "Parity Bit:"
            Label1(4).Caption = "Stop Bit:"
          
             Frame1.Caption = "SN Type"
             Frame3.Caption = "Total len-StartBit- EndBit"
      
Case 1
   Label3.Caption = "View Sonic 条码烧录"
   Label7.Caption = "版本:V1.3" & vbCrLf & "日期:2006/02/23"
   
   For i = 0 To SSTab1.Tabs - 1
     SSTab1.Tab = i
     If i = 0 Then
          SSTab1.Caption = "发送SN主窗口"
       ElseIf i = 1 Then
          SSTab1.Caption = "端口设定"
       ElseIf i = 2 Then
          SSTab1.Caption = "其它设定"
     End If
    Next

            Label8.Caption = "发送SN: "
            Label2.Caption = "串口状态"
            CmdSend.Caption = "发送"
            Cmdpause.Caption = "中断"
            CmdExit.Caption = "退出"
            
            Label1(3).Caption = "端口"
            Label1(2).Caption = "波特率"
            Label1(8).Caption = "串口"
            Label1(7).Caption = "参数:"
            CmdOK.Caption = "确定"
            Frame2.Caption = "参数设定"
            Label1(6).Caption = "数据位:"
            Label1(5).Caption = "检验位:"
            Label1(4).Caption = "停止位:"
          
             Frame1.Caption = "条码类型"
             Frame3.Caption = "总位数-SN初位-SN末位"
       
End Select

 SSTab1.Tab = iSSTab
End Sub
Private Sub CmdCLear_Click() 'test use: Set recycle number of Barcode
Dim str As String
PauseNumber = 0
str = InputBox("输入循环个数")
RecycleNum = Val(Trim(str))
  
End Sub
Private Sub CmdOK_Click()

If MSComm1.PortOpen = True Then
   MSComm1.PortOpen = False
End If

MSComm1.CommPort = cboPort.ListIndex + 1         ' Set the new port number.
MSComm1.Settings = Trim$(cboSpeed.Text) & "," & Left$(cboParity.Text, 1) _
    & "," & Trim$(cboDataBits.Text) & "," & Trim$(cboStopBits.Text)
If Err Then
    MsgBox Error$, 48
    Exit Sub
End If

Label5 = MSComm1.CommPort
Label6 = MSComm1.Settings

CurrentPort = MSComm1.CommPort
CurrentSettings = MSComm1.Settings
End Sub


Private Sub CmdPause_Click()
   bRun = False
If MSComm1.PortOpen = True Then
   MSComm1.PortOpen = False
 End If
 Delay (100)

   If CboLanguage.ListIndex = 1 Then
        Label2.Caption = "串口已断开"
      Else
        Label2.Caption = "Disconnected"
   End If
Text1.Enabled = True
CmdSend.Enabled = True
End Sub
Private Sub CmdExit_Click()
Dim msg As String
msg = MsgBox("Leave really?", vbYesNo, "Exit!")
  If msg = 6 Then
    If MSComm1.PortOpen = True Then
       MSComm1.PortOpen = False
    End If
    End
  ElseIf msg = 7 Then
  End If
End Sub
Private Sub Form_Load() '初始化串口参数,条码长度及有效始末位,PreLoad ComboBox Items

CurrentSettings = "9600,n,8,1"
CurrentPort = 1
MSComm1.CommPort = CurrentPort
MSComm1.Settings = CurrentSettings

Label5.Caption = CurrentPort
Label6.Caption = CurrentSettings

BarcodeLen = Val(Mid(Option1.Caption, 1, 2))
BarcodeStart = Val(Mid(Option1.Caption, 6, 2))
BarcodeEnd = Val(Mid(Option1.Caption, 11, 2))

 Slider_DelayTime.Value = 9999
 Slider_DelayTimes.Value = 3
 Delay_Time = Slider_DelayTime.Value
 Delay_Times = Slider_DelayTimes.Value
 Txt_Show.Text = "(" & Delay_Times & "," & Delay_Time & ")"
 
LoadPropertySettings
LoadLanguageSettings

End Sub

Private Sub Delay(n As Long)
Dim i As Integer
For i = 1 To n
 DoEvents 'nop()
Next
End Sub

Private Sub Form_Unload(Cancel As Integer)
bRun = False
End Sub

Private Sub Mscomm1_Oncomm()
'...通讯事件发生

Select Case MSComm1.CommEvent
       Case comEvReceive '...有接受事件发生
               MsgBox "OKOKOKOK!!!" & vbCrLf & "成功发送!!!"
               'Exit Sub
               Text2.Text = MSComm1.Input  '...接受显示数据
               MSComm1.InBufferCount = 0 '...清空输入寄存器
    
                'List1.FontSize = 12
                'List1.AddItem (Text1.Text)
                'Label4.Caption = "条码扫描完毕......"
       Case comEvSend
                Text1.Text = MSComm1.OutBufferCount
                Text2.Text = MSComm1.InBufferCount

⌨️ 快捷键说明

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