简体   繁体   English

将数据从DataGridView发送到串行端口

[英]Send Data from DataGridView to serial port

I'm programming a windows form. 我正在编写Windows窗体。 One of its functions is to send the values input in a DatagridView through the serial port. 它的功能之一是通过串行端口发送在DatagridView中输入的值。 Only it does not work. 只有它不起作用。 Here are a screenshot and the error code. 这是屏幕截图和错误代码。 I think it is the last empty row of the DG. 我认为这是DG的最后一个空白行。 Please let me know what you think is the problem. 请让我知道您的想法。

Code

Windows Form Windows表格

The outputbuffer variable in concatenated with the variables I want to send and then sent with serial port. outputbuffer变量与我要发送的变量串联在一起,然后通过串行端口发送。 Is the last row the problem? 最后一行是问题吗?

Should I add the word New before redifining. 我应该在重新定义之前添加“新建”一词。

COuld you suggest a code to send the data in DG to serial with Vb.net ? 您能否建议一个代码,以将DG中的数据发送到Vb.net串行? I'm quite the beginner. 我是个初学者。

thank you! 谢谢!

What is not working? 什么不起作用? What are you trying to talk with? 你想和谁说话?

You could use Com0Com to test your communication, but you should provide more info about your problem. 您可以使用Com0Com来测试您的通讯,但是您应该提供有关问题的更多信息。

Do this 'thing' use control characters? 这个“东西”使用控制字符吗? Did you look, if your SeriaPort configuration matches the serial configuration of the device you are talking with? 您是否看过,如果您的SeriaPort配置与您正在使用的设备的串行配置相匹配? Do this device expect a dataread before executing the next command? 该设备在执行下一个命令之前是否希望读取数据?

You should describe your problem a little better and exactly. 您应该更好地,准确地描述您的问题。

The error says you are using an object that doesnt exist. 该错误表明您正在使用不存在的对象。 You get the same error if you do like that: 如果您这样做,将会得到相同的错误:

Dim string as String
Dim stringLength = string.Length

You need an instance of the object you are using. 您需要使用的对象的实例。

If you delete .ToString() you should get desired result. 如果删除.ToString(),则应获得期望的结果。

And you should use ListView instead of DGV. 并且您应该使用ListView而不是DGV。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM