vb.net 在visual basic 2010 express中添加和使用MSCOMM

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15428957/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 12:48:31  来源:igfitidea点击:

Adding & Use MSCOMM in visual basic 2010 express

.netvb.netserial-portmscomm32

提问by whywhy

i already add the mycomm.lib into my visual basic by clicking Project-> Add reference -> Com Tab -> choose mycomm control 6.0. But i still dunno how to use it. What i want is to send a character From visual basic express 2010 to Microcontroller.

我已经通过单击 Project-> Add reference -> Com Tab -> 选择 mycomm control 6.0 将 mycomm.lib 添加到我的 Visual Basic 中。但我仍然不知道如何使用它。我想要的是将一个字符从visual basic express 2010发送到微控制器。

回答by Cody Gray

The MSComm Control 6.0 is intended for use with a veryold version of Visual Basic (VB 6.0) that is completely incompatible with VB.NET (which is what you have now, in Visual Basic 2010). This old control is provided only for backwards compatibility and is not recommended for use in new applications.

MSComm Control 6.0 旨在用于与 VB.NET 完全不兼容的非常旧版本的 Visual Basic (VB 6.0)(这是您现在在 Visual Basic 2010 中拥有的版本)。提供此旧控件仅用于向后兼容,不建议在新应用程序中使用。

The .NET Framework provides the System.IO.Ports.SerialPortclass, which is what you should be using instead. I think you'll find it much easier to work with, since it was designed with VB.NET in mind.

.NET Framework 提供了System.IO.Ports.SerialPort,您应该使用它来代替。我想你会发现它更容易使用,因为它是为 VB.NET 设计的。

You can find some very comprehensive sample code at the bottom of the above-linked documentation. And if that doesn't serve your purposes, you can surely find lots of sample code elsewhere online now that you know the magic term to unlock the oracle of Google.

您可以在上面链接的文档底部找到一些非常全面的示例代码。如果这不符合您的目的,那么您肯定可以在网上其他地方找到许多示例代码,因为您知道解锁 Google 神谕的神奇术语。