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

📄 form1.frm

📁 一个将扫描枪RS232输出格式自动转换为PS/2键盘格式输入的小程式
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmSetting 
   Caption         =   "设置介面"
   ClientHeight    =   2175
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3360
   LinkTopic       =   "Form1"
   ScaleHeight     =   2175
   ScaleWidth      =   3360
   StartUpPosition =   3  '窗口缺省
   Begin VB.ComboBox Combo2 
      Height          =   300
      ItemData        =   "Form1.frx":0000
      Left            =   2040
      List            =   "Form1.frx":000A
      TabIndex        =   4
      Text            =   "是"
      Top             =   345
      Width           =   855
   End
   Begin VB.ComboBox Combo1 
      Height          =   300
      ItemData        =   "Form1.frx":0016
      Left            =   2040
      List            =   "Form1.frx":0029
      TabIndex        =   3
      Text            =   "1"
      Top             =   840
      Width           =   855
   End
   Begin VB.CommandButton Command1 
      Caption         =   "确   认"
      Height          =   375
      Left            =   960
      TabIndex        =   0
      Top             =   1560
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "请选择COM口:"
      Height          =   255
      Index           =   1
      Left            =   240
      TabIndex        =   2
      Top             =   863
      Width           =   1695
   End
   Begin VB.Label Label1 
      Caption         =   "是否自动运行程式:"
      Height          =   255
      Index           =   0
      Left            =   240
      TabIndex        =   1
      Top             =   368
      Width           =   1695
   End
End
Attribute VB_Name = "frmSetting"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
If Combo2.Text = "是" Then
  AutoRun = 1
Else
  AutoRun = 0
End If
ComPortNum = CInt(Combo1.Text)
ChangeSetting
On Error GoTo ErrDeal
With FrmMain.MSComm1
     If .PortOpen = True Then .PortOpen = False
     .Handshaking = comRTS
     .CommPort = ComPortNum              '使用COM1
     .Settings = "9600,n,8,1"       '设置通信口参数
     .InBufferSize = 40     '设置MSComm1接收缓冲区为40字节
     .OutBufferSize = 18     '设置MSComm1发送缓冲区为2字节
     .InputMode = comInputModeText    '设置接收数据模式为二进制形式
     .InputLen = 0     '设置Input 一次从接收缓冲读取字节数为1
     .SThreshold = 0    '设置Output 一次从发送缓冲读取字节数为1
     .InBufferCount = 0 '清除接收缓冲区
'     .OutBufferiCount = 0     '清除发送缓冲区
     .RThreshold = 1    '设置接收一个字节产生OnComm事件
     .PortOpen = True       '打开通信口
  End With
Unload Me
Exit Sub
ErrDeal:
  MsgBox "设置的COM端口号无效,请重新设置!", vbInformation, "提示"
End Sub

Private Sub Form_Load()
If AutoRun = 1 Then
  Combo2.Text = "是"
End If
If ComPortNum > 1 Then Combo1.ListIndex = ComPortNum - 1
End Sub

⌨️ 快捷键说明

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