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

📄 form1.vb

📁 在vb.net 中如何使用计算机的串口
💻 VB
📖 第 1 页 / 共 2 页
字号:
Imports System.Text
Imports System.Environment
Imports System.management
Imports Scripting

Public Class frmMain
    Inherits System.Windows.Forms.Form
    Private m_CommPort As New Rs232
    Private m_ModemPort As Integer = 0
    Dim com As Integer
    Dim baud As Integer
    Dim Parity As Integer
    Dim StopBit As Integer
    Dim DataNum As Integer

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    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

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents btnSend As System.Windows.Forms.Button
    Friend WithEvents lblReceive As System.Windows.Forms.Label
    Friend WithEvents lblSend As System.Windows.Forms.Label
    Friend WithEvents btnOpen As System.Windows.Forms.Button
    Friend WithEvents linkMe As System.Windows.Forms.LinkLabel
    Friend WithEvents txtReceive As System.Windows.Forms.RichTextBox
    Friend WithEvents btnClose As System.Windows.Forms.Button
    Friend WithEvents cbBaud As System.Windows.Forms.ComboBox
    Friend WithEvents cbCom As System.Windows.Forms.ComboBox
    Friend WithEvents tmrReadCommPort As System.Windows.Forms.Timer
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents txtSend As System.Windows.Forms.RichTextBox
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents chkEnter As System.Windows.Forms.CheckBox
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
    Friend WithEvents cbData As System.Windows.Forms.ComboBox
    Friend WithEvents cbStop As System.Windows.Forms.ComboBox
    Friend WithEvents cbCheck As System.Windows.Forms.ComboBox
    Friend WithEvents btnClear As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMain))
        Me.btnSend = New System.Windows.Forms.Button
        Me.lblReceive = New System.Windows.Forms.Label
        Me.lblSend = New System.Windows.Forms.Label
        Me.txtReceive = New System.Windows.Forms.RichTextBox
        Me.btnOpen = New System.Windows.Forms.Button
        Me.linkMe = New System.Windows.Forms.LinkLabel
        Me.btnClose = New System.Windows.Forms.Button
        Me.cbBaud = New System.Windows.Forms.ComboBox
        Me.cbCom = New System.Windows.Forms.ComboBox
        Me.tmrReadCommPort = New System.Windows.Forms.Timer(Me.components)
        Me.cbData = New System.Windows.Forms.ComboBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.cbStop = New System.Windows.Forms.ComboBox
        Me.Label5 = New System.Windows.Forms.Label
        Me.cbCheck = New System.Windows.Forms.ComboBox
        Me.Label6 = New System.Windows.Forms.Label
        Me.txtSend = New System.Windows.Forms.RichTextBox
        Me.Label7 = New System.Windows.Forms.Label
        Me.chkEnter = New System.Windows.Forms.CheckBox
        Me.PictureBox1 = New System.Windows.Forms.PictureBox
        Me.btnClear = New System.Windows.Forms.Button
        CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'btnSend
        '
        Me.btnSend.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.btnSend.Location = New System.Drawing.Point(699, 536)
        Me.btnSend.Name = "btnSend"
        Me.btnSend.Size = New System.Drawing.Size(84, 28)
        Me.btnSend.TabIndex = 0
        Me.btnSend.Text = "(&S)发送"
        '
        'lblReceive
        '
        Me.lblReceive.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.lblReceive.Location = New System.Drawing.Point(0, 73)
        Me.lblReceive.Name = "lblReceive"
        Me.lblReceive.Size = New System.Drawing.Size(8, 18)
        Me.lblReceive.TabIndex = 2
        Me.lblReceive.Text = "以下为接收到的数据"
        '
        'lblSend
        '
        Me.lblSend.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.lblSend.Location = New System.Drawing.Point(0, 376)
        Me.lblSend.Name = "lblSend"
        Me.lblSend.Size = New System.Drawing.Size(17, 18)
        Me.lblSend.TabIndex = 3
        Me.lblSend.Text = "以下为需要发送的数据"
        '
        'txtReceive
        '
        Me.txtReceive.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.txtReceive.Location = New System.Drawing.Point(0, 91)
        Me.txtReceive.Name = "txtReceive"
        Me.txtReceive.Size = New System.Drawing.Size(689, 276)
        Me.txtReceive.TabIndex = 4
        Me.txtReceive.Text = ""
        '
        'btnOpen
        '
        Me.btnOpen.Location = New System.Drawing.Point(448, 37)
        Me.btnOpen.Name = "btnOpen"
        Me.btnOpen.Size = New System.Drawing.Size(84, 27)
        Me.btnOpen.TabIndex = 7
        Me.btnOpen.Text = "(&O)打开"
        '
        'linkMe
        '
        Me.linkMe.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.linkMe.Location = New System.Drawing.Point(709, 46)
        Me.linkMe.Name = "linkMe"
        Me.linkMe.Size = New System.Drawing.Size(0, 18)
        Me.linkMe.TabIndex = 8
        Me.linkMe.TabStop = True
        Me.linkMe.Text = "联系作者"
        '
        'btnClose
        '
        Me.btnClose.Enabled = False
        Me.btnClose.Location = New System.Drawing.Point(541, 37)
        Me.btnClose.Name = "btnClose"
        Me.btnClose.Size = New System.Drawing.Size(103, 27)
        Me.btnClose.TabIndex = 9
        Me.btnClose.Text = "(&C)关闭"
        '
        'cbBaud
        '
        Me.cbBaud.Items.AddRange(New Object() {"1200", "2400", "4800", "9600", "19200", "38400", "57600", "115200", "230400", "460800"})
        Me.cbBaud.Location = New System.Drawing.Point(93, 37)
        Me.cbBaud.Name = "cbBaud"
        Me.cbBaud.Size = New System.Drawing.Size(84, 22)
        Me.cbBaud.TabIndex = 10
        '
        'cbCom
        '
        Me.cbCom.Items.AddRange(New Object() {"COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8"})
        Me.cbCom.Location = New System.Drawing.Point(9, 37)
        Me.cbCom.Name = "cbCom"
        Me.cbCom.Size = New System.Drawing.Size(66, 22)
        Me.cbCom.TabIndex = 11
        '
        'tmrReadCommPort
        '
        '
        'cbData
        '
        Me.cbData.Items.AddRange(New Object() {"8", "7"})
        Me.cbData.Location = New System.Drawing.Point(196, 37)
        Me.cbData.Name = "cbData"
        Me.cbData.Size = New System.Drawing.Size(65, 22)
        Me.cbData.TabIndex = 12
        '
        'Label1

⌨️ 快捷键说明

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