📄 form1.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
'// Private members
Private miComPort As Integer
Friend WithEvents btnOpenCom As System.Windows.Forms.Button
Friend WithEvents btnCloseCom As System.Windows.Forms.Button
Friend WithEvents btnTx As System.Windows.Forms.Button
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents txtTx As System.Windows.Forms.TextBox
Friend WithEvents txtRx As System.Windows.Forms.TextBox
Friend WithEvents btnRx As System.Windows.Forms.Button
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents txtBytes2Read As System.Windows.Forms.TextBox
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents optCom2 As System.Windows.Forms.RadioButton
Friend WithEvents optCom1 As System.Windows.Forms.RadioButton
Friend WithEvents txtTimeout As System.Windows.Forms.TextBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents txtBaudrate As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip
Friend WithEvents chkAutorx As System.Windows.Forms.CheckBox
Friend WithEvents chkRTS As System.Windows.Forms.CheckBox
Friend WithEvents chkDTR As System.Windows.Forms.CheckBox
Friend WithEvents btnExit As System.Windows.Forms.Button
Private WithEvents moRS232 As Rs232
Private mlTicks As Long
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Private components As System.ComponentModel.IContainer
'Required by the Windows Form Designer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents linkAuthor As System.Windows.Forms.LinkLabel
Friend WithEvents lbHex As System.Windows.Forms.ListBox
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents cboStatusLine As System.Windows.Forms.ComboBox
Friend WithEvents btnCheck As System.Windows.Forms.Button
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents chkOl As System.Windows.Forms.CheckBox
Friend WithEvents btnAsyncTx As System.Windows.Forms.Button
Friend WithEvents btnAsync As System.Windows.Forms.Button
Friend WithEvents lbAsync As System.Windows.Forms.ListBox
Friend WithEvents lblAsync As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
Me.chkRTS = New System.Windows.Forms.CheckBox
Me.btnTx = New System.Windows.Forms.Button
Me.txtTimeout = New System.Windows.Forms.TextBox
Me.txtTx = New System.Windows.Forms.TextBox
Me.chkAutorx = New System.Windows.Forms.CheckBox
Me.btnOpenCom = New System.Windows.Forms.Button
Me.txtBaudrate = New System.Windows.Forms.TextBox
Me.btnRx = New System.Windows.Forms.Button
Me.txtBytes2Read = New System.Windows.Forms.TextBox
Me.chkDTR = New System.Windows.Forms.CheckBox
Me.chkOl = New System.Windows.Forms.CheckBox
Me.btnAsyncTx = New System.Windows.Forms.Button
Me.btnAsync = New System.Windows.Forms.Button
Me.lbAsync = New System.Windows.Forms.ListBox
Me.Label5 = New System.Windows.Forms.Label
Me.Label1 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.txtRx = New System.Windows.Forms.TextBox
Me.optCom1 = New System.Windows.Forms.RadioButton
Me.btnCloseCom = New System.Windows.Forms.Button
Me.optCom2 = New System.Windows.Forms.RadioButton
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.btnExit = New System.Windows.Forms.Button
Me.linkAuthor = New System.Windows.Forms.LinkLabel
Me.lbHex = New System.Windows.Forms.ListBox
Me.Label6 = New System.Windows.Forms.Label
Me.cboStatusLine = New System.Windows.Forms.ComboBox
Me.btnCheck = New System.Windows.Forms.Button
Me.Label7 = New System.Windows.Forms.Label
Me.lblAsync = New System.Windows.Forms.Label
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'chkRTS
'
Me.chkRTS.Checked = True
Me.chkRTS.CheckState = System.Windows.Forms.CheckState.Checked
Me.chkRTS.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.chkRTS.Location = New System.Drawing.Point(212, 90)
Me.chkRTS.Name = "chkRTS"
Me.chkRTS.Size = New System.Drawing.Size(63, 19)
Me.chkRTS.TabIndex = 3
Me.chkRTS.Text = "RTS"
Me.ToolTip1.SetToolTip(Me.chkRTS, "Set state of RTS Line")
'
'btnTx
'
Me.btnTx.Enabled = False
Me.btnTx.Location = New System.Drawing.Point(216, 126)
Me.btnTx.Name = "btnTx"
Me.btnTx.Size = New System.Drawing.Size(60, 17)
Me.btnTx.TabIndex = 7
Me.btnTx.Text = "Tx"
Me.ToolTip1.SetToolTip(Me.btnTx, "Sends data to COM Port")
'
'txtTimeout
'
Me.txtTimeout.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.txtTimeout.Location = New System.Drawing.Point(69, 32)
Me.txtTimeout.Name = "txtTimeout"
Me.txtTimeout.Size = New System.Drawing.Size(65, 21)
Me.txtTimeout.TabIndex = 3
Me.txtTimeout.Text = "500"
Me.ToolTip1.SetToolTip(Me.txtTimeout, "COM Port timeout in ms")
'
'txtTx
'
Me.txtTx.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.txtTx.Location = New System.Drawing.Point(7, 134)
Me.txtTx.Name = "txtTx"
Me.txtTx.Size = New System.Drawing.Size(200, 21)
Me.txtTx.TabIndex = 6
Me.txtTx.Text = "ATDT00121233854111"
Me.ToolTip1.SetToolTip(Me.txtTx, "Type data you want to send")
'
'chkAutorx
'
Me.chkAutorx.Checked = True
Me.chkAutorx.CheckState = System.Windows.Forms.CheckState.Checked
Me.chkAutorx.Location = New System.Drawing.Point(8, 342)
Me.chkAutorx.Name = "chkAutorx"
Me.chkAutorx.Size = New System.Drawing.Size(185, 15)
Me.chkAutorx.TabIndex = 13
Me.chkAutorx.Text = "Automatically receive bytes"
Me.ToolTip1.SetToolTip(Me.chkAutorx, "After a Tx tries to Rx bytes")
'
'btnOpenCom
'
Me.btnOpenCom.Location = New System.Drawing.Point(210, 19)
Me.btnOpenCom.Name = "btnOpenCom"
Me.btnOpenCom.Size = New System.Drawing.Size(95, 27)
Me.btnOpenCom.TabIndex = 1
Me.btnOpenCom.Text = "Open COM Port"
Me.ToolTip1.SetToolTip(Me.btnOpenCom, "Initializes and Open COM port")
'
'txtBaudrate
'
Me.txtBaudrate.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.txtBaudrate.Location = New System.Drawing.Point(69, 68)
Me.txtBaudrate.Name = "txtBaudrate"
Me.txtBaudrate.Size = New System.Drawing.Size(65, 21)
Me.txtBaudrate.TabIndex = 5
Me.txtBaudrate.Text = "19200"
Me.ToolTip1.SetToolTip(Me.txtBaudrate, "COM Port Baudrate")
'
'btnRx
'
Me.btnRx.Enabled = False
Me.btnRx.Location = New System.Drawing.Point(7, 293)
Me.btnRx.Name = "btnRx"
Me.btnRx.Size = New System.Drawing.Size(58, 19)
Me.btnRx.TabIndex = 10
Me.btnRx.Text = "Rx"
Me.ToolTip1.SetToolTip(Me.btnRx, "Reads COM Buffer")
'
'txtBytes2Read
'
Me.txtBytes2Read.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.txtBytes2Read.Location = New System.Drawing.Point(245, 305)
Me.txtBytes2Read.Name = "txtBytes2Read"
Me.txtBytes2Read.Size = New System.Drawing.Size(65, 21)
Me.txtBytes2Read.TabIndex = 12
Me.txtBytes2Read.Text = "34"
Me.ToolTip1.SetToolTip(Me.txtBytes2Read, "Bytes to read from COM buffer")
'
'chkDTR
'
Me.chkDTR.Checked = True
Me.chkDTR.CheckState = System.Windows.Forms.CheckState.Checked
Me.chkDTR.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.chkDTR.Location = New System.Drawing.Point(260, 90)
Me.chkDTR.Name = "chkDTR"
Me.chkDTR.Size = New System.Drawing.Size(63, 19)
Me.chkDTR.TabIndex = 4
Me.chkDTR.Text = "DTR"
Me.ToolTip1.SetToolTip(Me.chkDTR, "Set state of DTR Line")
'
'chkOl
'
Me.chkOl.Location = New System.Drawing.Point(168, 343)
Me.chkOl.Name = "chkOl"
Me.chkOl.Size = New System.Drawing.Size(129, 13)
Me.chkOl.TabIndex = 21
Me.chkOl.Text = "Overlapped Mode"
Me.ToolTip1.SetToolTip(Me.chkOl, "Open port in overlapped mode")
'
'btnAsyncTx
'
Me.btnAsyncTx.Enabled = False
Me.btnAsyncTx.Location = New System.Drawing.Point(217, 148)
Me.btnAsyncTx.Name = "btnAsyncTx"
Me.btnAsyncTx.Size = New System.Drawing.Size(58, 17)
Me.btnAsyncTx.TabIndex = 23
Me.btnAsyncTx.Text = "Async Tx"
Me.ToolTip1.SetToolTip(Me.btnAsyncTx, "Sends data to COM Port (Async Mode)")
'
'btnAsync
'
Me.btnAsync.Enabled = False
Me.btnAsync.Location = New System.Drawing.Point(7, 315)
Me.btnAsync.Name = "btnAsync"
Me.btnAsync.Size = New System.Drawing.Size(58, 19)
Me.btnAsync.TabIndex = 24
Me.btnAsync.Text = "Async Rx"
Me.ToolTip1.SetToolTip(Me.btnAsync, "Reads COM Buffer (Async method)")
'
'lbAsync
'
Me.lbAsync.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.lbAsync.Location = New System.Drawing.Point(7, 376)
Me.lbAsync.Name = "lbAsync"
Me.lbAsync.Size = New System.Drawing.Size(305, 54)
Me.lbAsync.TabIndex = 25
Me.ToolTip1.SetToolTip(Me.lbAsync, "Async method sequence")
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(240, 290)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(82, 14)
Me.Label5.TabIndex = 11
Me.Label5.Text = "Bytes to read"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(69, 18)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(82, 14)
Me.Label1.TabIndex = 2
Me.Label1.Text = "Timeout (ms)"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(69, 54)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(82, 14)
Me.Label4.TabIndex = 4
Me.Label4.Text = "BaudRate"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(7, 164)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(82, 14)
Me.Label3.TabIndex = 8
Me.Label3.Text = "Received Data"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(7, 120)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(82, 14)
Me.Label2.TabIndex = 5
Me.Label2.Text = "Data to Tx"
'
'txtRx
'
Me.txtRx.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.txtRx.Location = New System.Drawing.Point(7, 178)
Me.txtRx.Multiline = True
Me.txtRx.Name = "txtRx"
Me.txtRx.Size = New System.Drawing.Size(305, 44)
Me.txtRx.TabIndex = 9
Me.txtRx.Text = ""
'
'optCom1
'
Me.optCom1.Checked = True
Me.optCom1.Location = New System.Drawing.Point(8, 32)
Me.optCom1.Name = "optCom1"
Me.optCom1.Size = New System.Drawing.Size(64, 26)
Me.optCom1.TabIndex = 0
Me.optCom1.TabStop = True
Me.optCom1.Text = "COM &1"
'
'btnCloseCom
'
Me.btnCloseCom.Enabled = False
Me.btnCloseCom.Location = New System.Drawing.Point(211, 51)
Me.btnCloseCom.Name = "btnCloseCom"
Me.btnCloseCom.Size = New System.Drawing.Size(95, 27)
Me.btnCloseCom.TabIndex = 2
Me.btnCloseCom.Text = "Close COM Port"
'
'optCom2
'
Me.optCom2.Location = New System.Drawing.Point(8, 56)
Me.optCom2.Name = "optCom2"
Me.optCom2.Size = New System.Drawing.Size(66, 26)
Me.optCom2.TabIndex = 1
Me.optCom2.Text = "COM &2"
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.txtTimeout)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -