📄 form2.vb
字号:
Public Class Form2
Inherits System.Windows.Forms.Form
Friend WithEvents NumericUpDown1 As System.Windows.Forms.NumericUpDown
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button1 As System.Windows.Forms.Button
Public WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
MyBase.Dispose(disposing)
End Sub
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.NumericUpDown1 = New System.Windows.Forms.NumericUpDown
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button2 = New System.Windows.Forms.Button
Me.Button1 = New System.Windows.Forms.Button
Me.Label2 = New System.Windows.Forms.Label
Me.Label1 = New System.Windows.Forms.Label
Me.TextBox2 = New System.Windows.Forms.TextBox
'
'NumericUpDown1
'
Me.NumericUpDown1.Location = New System.Drawing.Point(80, 192)
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(96, 16)
Me.TextBox1.Text = ""
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(152, 112)
Me.Button2.Size = New System.Drawing.Size(72, 24)
Me.Button2.Text = "退出"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(24, 112)
Me.Button1.Size = New System.Drawing.Size(72, 24)
Me.Button1.Text = "确认"
'
'Label2
'
Me.Label2.ForeColor = System.Drawing.SystemColors.ControlDarkDark
Me.Label2.Location = New System.Drawing.Point(16, 56)
Me.Label2.Size = New System.Drawing.Size(80, 16)
Me.Label2.Text = "条码长度:"
'
'Label1
'
Me.Label1.ForeColor = System.Drawing.SystemColors.ControlDarkDark
Me.Label1.Location = New System.Drawing.Point(16, 24)
Me.Label1.Size = New System.Drawing.Size(100, 13)
Me.Label1.Text = "输入文件名:"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(96, 56)
Me.TextBox2.Text = ""
'
'Form2
'
Me.ClientSize = New System.Drawing.Size(234, 159)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.NumericUpDown1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.MaximizeBox = False
Me.Text = "扫描设置"
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Len(Trim(TextBox1.Text)) < 1 Then
MsgBox("文件名不能为空!", MsgBoxStyle.DefaultButton1, "错误")
Exit Sub
End If
P_filename = P_path + Trim(TextBox1.Text) + ".txt"
P_barlen = Val(NumericUpDown1.Value)
Dim frm3 As New Form3
frm3.Show()
Me.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Close()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Focus()
End Sub
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyValue = 13 Then
TextBox2.Focus()
End If
End Sub
Private Sub NumericUpDown1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles NumericUpDown1.KeyDown
If e.KeyValue = 13 Then
If Len(Trim(TextBox1.Text)) < 1 Then
MsgBox("文件名不能为空!", MsgBoxStyle.DefaultButton1, "错误")
TextBox1.Focus()
Exit Sub
End If
P_filename = P_path + Trim(TextBox1.Text) + ".txt"
P_barlen = Val(NumericUpDown1.Value)
Dim frm3 As New Form3
frm3.Show()
Me.Close()
End If
End Sub
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
End Sub
Private Sub TextBox2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox2.KeyDown
If e.KeyValue = 13 Then
If Val(Trim(TextBox2.Text)) > 0 Then
NumericUpDown1.Value = Trim(TextBox2.Text)
If Len(Trim(TextBox1.Text)) < 1 Then
MsgBox("文件名不能为空!", MsgBoxStyle.DefaultButton1, "错误")
TextBox1.Focus()
Exit Sub
End If
P_filename = P_path + Trim(TextBox1.Text) + ".txt"
P_barlen = Val(NumericUpDown1.Value)
Dim frm3 As New Form3
frm3.ShowDialog()
Me.Close()
Else
TextBox2.Focus()
End If
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -