SerialPort获取端口名称和编号 [英] SerialPort Get port name and number

查看:99
本文介绍了SerialPort获取端口名称和编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
使用此代码,我可以毫无问题地获得端口号"COM10"

Hey all
I can get the port number like "COM10" without any problems using this code

<pre lang="vb">''When the form loads<br />
''Enumerate available Com ports and add to ComboBox1<br />
comPorts = IO.Ports.SerialPort.GetPortNames()<br />
For i = 0 To UBound(comPorts)<br />
    ComboBox1.Items.Add(comPorts(i))<br />
Next<br />
''Set ComboBox1 text to first available port<br />
ComboBox1.Text = ComboBox1.Items.Item(0)<br />
''Set SerialPort1 portname to first available port<br />
SerialPort1.PortName = ComboBox1.Text<br />
''Set remaining port attributes<br />
SerialPort1.BaudRate = 19200<br />
SerialPort1.Parity = IO.Ports.Parity.None<br />
SerialPort1.StopBits = IO.Ports.StopBits.One<br />
SerialPort1.DataBits = 8</pre><br />


但我想像"COM10 HUAWEI MOBILE CONNECT"那样得到它
在Advance中致谢


But i want to get it like "COM10 HUAWEI MOBILE CONNECT"
Thanks in Advance

推荐答案

尝试
SerialPort.PortName [获取串行端口信息[
Try
SerialPort.PortName[^]
Getting Serial Port Information [^]


SerialPort.PortName Property
Gets or sets the port for communications, including but not limited to all available COM ports.


这篇关于SerialPort获取端口名称和编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆