如何在Button2_Click中使用Button1_Click串行端口 [英] How to use Button1_Click Serialport in Button2_Click

查看:114
本文介绍了如何在Button2_Click中使用Button1_Click串行端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有人都好,

我正在开发一个vb应用程序.在那我在Button1_Click事件中使用Serialport.但是现在我想在Button2_Click事件中使用相同的串行端口.....
请帮助我

感谢ADV .....

Hai to all,

I am developing one vb application . In that i am using Serialport in Button1_Click Event. But now i want to use the same serialport in Button2_Click event.....
Plz help me

Thanks in ADV.....

推荐答案

将SerialPort变量的声明移到Button1事件处理程序之外.如果它是一个类级别(即在表单内),则相同形式的两个按钮处理程序都可以访问它.
Move the declaration of the SerialPort Variable outside the Button1 event handler. If it is a class level (i.e. within the form) then both button handlers in the same form can access it.


这篇关于如何在Button2_Click中使用Button1_Click串行端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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