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

📄 frmmain.vb

📁 使用vb.net实现串口通讯的过程
💻 VB
📖 第 1 页 / 共 3 页
字号:
'Copyright (C) 2002 Microsoft Corporation
'All rights reserved.
'THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
'EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 
'MERCHANTIBILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

'Requires the Trial or Release version of Visual Studio .NET Professional (or greater).

Option Strict On

Imports System.Text

Public Class frmMain
	Inherits System.Windows.Forms.Form

    ' Declare necessary class variables.
    Private m_CommPort As New Rs232()
    Private m_IsModemFound As Boolean = False
    Private m_ModemPort As Integer = 0

#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

		' So that we only need to set the title of the application once,
		' we use the AssemblyInfo class (defined in the AssemblyInfo.vb file)
		' to read the AssemblyTitle attribute.
		Dim ainfo As New AssemblyInfo()

		Me.Text = ainfo.Title
		Me.mnuAbout.Text = String.Format("&About {0} ...", ainfo.Title)

	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

	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer

	'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 mnuMain As System.Windows.Forms.MainMenu
	Friend WithEvents mnuFile As System.Windows.Forms.MenuItem
	Friend WithEvents mnuExit As System.Windows.Forms.MenuItem
	Friend WithEvents mnuHelp As System.Windows.Forms.MenuItem
	Friend WithEvents mnuAbout As System.Windows.Forms.MenuItem
    Friend WithEvents txtStatus As System.Windows.Forms.TextBox
    Friend WithEvents tmrReadCommPort As System.Windows.Forms.Timer
    Friend WithEvents clstPorts As System.Windows.Forms.CheckedListBox
    Friend WithEvents btnCheckForPorts As System.Windows.Forms.Button
    Friend WithEvents btnCheckModems As System.Windows.Forms.Button
    Friend WithEvents txtSelectedModem As System.Windows.Forms.TextBox
    Friend WithEvents btnSendATCommand As System.Windows.Forms.Button
    Friend WithEvents txtUserCommand As System.Windows.Forms.TextBox
    Friend WithEvents btnSendUserCommand As System.Windows.Forms.Button
    Friend WithEvents btnClear As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmMain))
        Me.mnuMain = New System.Windows.Forms.MainMenu
        Me.mnuFile = New System.Windows.Forms.MenuItem
        Me.mnuExit = New System.Windows.Forms.MenuItem
        Me.mnuHelp = New System.Windows.Forms.MenuItem
        Me.mnuAbout = New System.Windows.Forms.MenuItem
        Me.btnCheckForPorts = New System.Windows.Forms.Button
        Me.txtStatus = New System.Windows.Forms.TextBox
        Me.tmrReadCommPort = New System.Windows.Forms.Timer(Me.components)
        Me.clstPorts = New System.Windows.Forms.CheckedListBox
        Me.btnCheckModems = New System.Windows.Forms.Button
        Me.txtSelectedModem = New System.Windows.Forms.TextBox
        Me.btnSendATCommand = New System.Windows.Forms.Button
        Me.btnSendUserCommand = New System.Windows.Forms.Button
        Me.txtUserCommand = New System.Windows.Forms.TextBox
        Me.btnClear = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'mnuMain
        '
        Me.mnuMain.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile, Me.mnuHelp})
        Me.mnuMain.RightToLeft = CType(resources.GetObject("mnuMain.RightToLeft"), System.Windows.Forms.RightToLeft)
        '
        'mnuFile
        '
        Me.mnuFile.Enabled = CType(resources.GetObject("mnuFile.Enabled"), Boolean)
        Me.mnuFile.Index = 0
        Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuExit})
        Me.mnuFile.Shortcut = CType(resources.GetObject("mnuFile.Shortcut"), System.Windows.Forms.Shortcut)
        Me.mnuFile.ShowShortcut = CType(resources.GetObject("mnuFile.ShowShortcut"), Boolean)
        Me.mnuFile.Text = resources.GetString("mnuFile.Text")
        Me.mnuFile.Visible = CType(resources.GetObject("mnuFile.Visible"), Boolean)
        '
        'mnuExit
        '
        Me.mnuExit.Enabled = CType(resources.GetObject("mnuExit.Enabled"), Boolean)
        Me.mnuExit.Index = 0
        Me.mnuExit.Shortcut = CType(resources.GetObject("mnuExit.Shortcut"), System.Windows.Forms.Shortcut)
        Me.mnuExit.ShowShortcut = CType(resources.GetObject("mnuExit.ShowShortcut"), Boolean)
        Me.mnuExit.Text = resources.GetString("mnuExit.Text")
        Me.mnuExit.Visible = CType(resources.GetObject("mnuExit.Visible"), Boolean)
        '
        'mnuHelp
        '
        Me.mnuHelp.Enabled = CType(resources.GetObject("mnuHelp.Enabled"), Boolean)
        Me.mnuHelp.Index = 1
        Me.mnuHelp.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuAbout})
        Me.mnuHelp.Shortcut = CType(resources.GetObject("mnuHelp.Shortcut"), System.Windows.Forms.Shortcut)
        Me.mnuHelp.ShowShortcut = CType(resources.GetObject("mnuHelp.ShowShortcut"), Boolean)
        Me.mnuHelp.Text = resources.GetString("mnuHelp.Text")
        Me.mnuHelp.Visible = CType(resources.GetObject("mnuHelp.Visible"), Boolean)
        '
        'mnuAbout
        '
        Me.mnuAbout.Enabled = CType(resources.GetObject("mnuAbout.Enabled"), Boolean)
        Me.mnuAbout.Index = 0
        Me.mnuAbout.Shortcut = CType(resources.GetObject("mnuAbout.Shortcut"), System.Windows.Forms.Shortcut)
        Me.mnuAbout.ShowShortcut = CType(resources.GetObject("mnuAbout.ShowShortcut"), Boolean)
        Me.mnuAbout.Text = resources.GetString("mnuAbout.Text")
        Me.mnuAbout.Visible = CType(resources.GetObject("mnuAbout.Visible"), Boolean)
        '
        'btnCheckForPorts
        '
        Me.btnCheckForPorts.AccessibleDescription = resources.GetString("btnCheckForPorts.AccessibleDescription")
        Me.btnCheckForPorts.AccessibleName = resources.GetString("btnCheckForPorts.AccessibleName")
        Me.btnCheckForPorts.Anchor = CType(resources.GetObject("btnCheckForPorts.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.btnCheckForPorts.BackgroundImage = CType(resources.GetObject("btnCheckForPorts.BackgroundImage"), System.Drawing.Image)
        Me.btnCheckForPorts.Dock = CType(resources.GetObject("btnCheckForPorts.Dock"), System.Windows.Forms.DockStyle)
        Me.btnCheckForPorts.Enabled = CType(resources.GetObject("btnCheckForPorts.Enabled"), Boolean)
        Me.btnCheckForPorts.FlatStyle = CType(resources.GetObject("btnCheckForPorts.FlatStyle"), System.Windows.Forms.FlatStyle)
        Me.btnCheckForPorts.Font = CType(resources.GetObject("btnCheckForPorts.Font"), System.Drawing.Font)
        Me.btnCheckForPorts.Image = CType(resources.GetObject("btnCheckForPorts.Image"), System.Drawing.Image)
        Me.btnCheckForPorts.ImageAlign = CType(resources.GetObject("btnCheckForPorts.ImageAlign"), System.Drawing.ContentAlignment)
        Me.btnCheckForPorts.ImageIndex = CType(resources.GetObject("btnCheckForPorts.ImageIndex"), Integer)
        Me.btnCheckForPorts.ImeMode = CType(resources.GetObject("btnCheckForPorts.ImeMode"), System.Windows.Forms.ImeMode)
        Me.btnCheckForPorts.Location = CType(resources.GetObject("btnCheckForPorts.Location"), System.Drawing.Point)
        Me.btnCheckForPorts.Name = "btnCheckForPorts"
        Me.btnCheckForPorts.RightToLeft = CType(resources.GetObject("btnCheckForPorts.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.btnCheckForPorts.Size = CType(resources.GetObject("btnCheckForPorts.Size"), System.Drawing.Size)
        Me.btnCheckForPorts.TabIndex = CType(resources.GetObject("btnCheckForPorts.TabIndex"), Integer)
        Me.btnCheckForPorts.Text = resources.GetString("btnCheckForPorts.Text")
        Me.btnCheckForPorts.TextAlign = CType(resources.GetObject("btnCheckForPorts.TextAlign"), System.Drawing.ContentAlignment)
        Me.btnCheckForPorts.Visible = CType(resources.GetObject("btnCheckForPorts.Visible"), Boolean)
        '
        'txtStatus
        '
        Me.txtStatus.AccessibleDescription = resources.GetString("txtStatus.AccessibleDescription")
        Me.txtStatus.AccessibleName = resources.GetString("txtStatus.AccessibleName")
        Me.txtStatus.Anchor = CType(resources.GetObject("txtStatus.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.txtStatus.AutoSize = CType(resources.GetObject("txtStatus.AutoSize"), Boolean)
        Me.txtStatus.BackgroundImage = CType(resources.GetObject("txtStatus.BackgroundImage"), System.Drawing.Image)
        Me.txtStatus.Dock = CType(resources.GetObject("txtStatus.Dock"), System.Windows.Forms.DockStyle)
        Me.txtStatus.Enabled = CType(resources.GetObject("txtStatus.Enabled"), Boolean)
        Me.txtStatus.Font = CType(resources.GetObject("txtStatus.Font"), System.Drawing.Font)
        Me.txtStatus.ImeMode = CType(resources.GetObject("txtStatus.ImeMode"), System.Windows.Forms.ImeMode)
        Me.txtStatus.Location = CType(resources.GetObject("txtStatus.Location"), System.Drawing.Point)
        Me.txtStatus.MaxLength = CType(resources.GetObject("txtStatus.MaxLength"), Integer)
        Me.txtStatus.Multiline = CType(resources.GetObject("txtStatus.Multiline"), Boolean)
        Me.txtStatus.Name = "txtStatus"
        Me.txtStatus.PasswordChar = CType(resources.GetObject("txtStatus.PasswordChar"), Char)
        Me.txtStatus.ReadOnly = True
        Me.txtStatus.RightToLeft = CType(resources.GetObject("txtStatus.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.txtStatus.ScrollBars = CType(resources.GetObject("txtStatus.ScrollBars"), System.Windows.Forms.ScrollBars)
        Me.txtStatus.Size = CType(resources.GetObject("txtStatus.Size"), System.Drawing.Size)
        Me.txtStatus.TabIndex = CType(resources.GetObject("txtStatus.TabIndex"), Integer)
        Me.txtStatus.Text = resources.GetString("txtStatus.Text")
        Me.txtStatus.TextAlign = CType(resources.GetObject("txtStatus.TextAlign"), System.Windows.Forms.HorizontalAlignment)
        Me.txtStatus.Visible = CType(resources.GetObject("txtStatus.Visible"), Boolean)
        Me.txtStatus.WordWrap = CType(resources.GetObject("txtStatus.WordWrap"), Boolean)
        '
        'tmrReadCommPort
        '
        '
        'clstPorts
        '
        Me.clstPorts.AccessibleDescription = resources.GetString("clstPorts.AccessibleDescription")
        Me.clstPorts.AccessibleName = resources.GetString("clstPorts.AccessibleName")
        Me.clstPorts.Anchor = CType(resources.GetObject("clstPorts.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.clstPorts.BackgroundImage = CType(resources.GetObject("clstPorts.BackgroundImage"), System.Drawing.Image)
        Me.clstPorts.ColumnWidth = CType(resources.GetObject("clstPorts.ColumnWidth"), Integer)
        Me.clstPorts.Dock = CType(resources.GetObject("clstPorts.Dock"), System.Windows.Forms.DockStyle)
        Me.clstPorts.Enabled = CType(resources.GetObject("clstPorts.Enabled"), Boolean)
        Me.clstPorts.Font = CType(resources.GetObject("clstPorts.Font"), System.Drawing.Font)
        Me.clstPorts.HorizontalExtent = CType(resources.GetObject("clstPorts.HorizontalExtent"), Integer)
        Me.clstPorts.HorizontalScrollbar = CType(resources.GetObject("clstPorts.HorizontalScrollbar"), Boolean)
        Me.clstPorts.ImeMode = CType(resources.GetObject("clstPorts.ImeMode"), System.Windows.Forms.ImeMode)
        Me.clstPorts.IntegralHeight = CType(resources.GetObject("clstPorts.IntegralHeight"), Boolean)
        Me.clstPorts.Items.AddRange(New Object() {resources.GetString("clstPorts.Items"), resources.GetString("clstPorts.Items1"), resources.GetString("clstPorts.Items2"), resources.GetString("clstPorts.Items3")})
        Me.clstPorts.Location = CType(resources.GetObject("clstPorts.Location"), System.Drawing.Point)
        Me.clstPorts.Name = "clstPorts"
        Me.clstPorts.RightToLeft = CType(resources.GetObject("clstPorts.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.clstPorts.ScrollAlwaysVisible = CType(resources.GetObject("clstPorts.ScrollAlwaysVisible"), Boolean)
        Me.clstPorts.Size = CType(resources.GetObject("clstPorts.Size"), System.Drawing.Size)
        Me.clstPorts.TabIndex = CType(resources.GetObject("clstPorts.TabIndex"), Integer)
        Me.clstPorts.TabStop = False
        Me.clstPorts.Visible = CType(resources.GetObject("clstPorts.Visible"), Boolean)

⌨️ 快捷键说明

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