如何将事件处理程序转换为VB Net [英] How do I Convert Event Handlers to VB Net
本文介绍了如何将事件处理程序转换为VB Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
以下是一些有效的C#代码:
Hi All,
Below is some C# code that works:
public Form1()
{
InitializeComponent();
SerialPinChangedEventHandler1 = new SerialPinChangedEventHandler(PinChanged);
myComPort.DataReceived +=
new System.IO.Ports.SerialDataReceivedEventHandler(port_DataReceived_1);
}
我要做的是用VB形式得到如下:
What I'm trying to do is get this in VB form as below:
SerialPinChangedEventHandler1 = New SerialPinChangedEventHandler(PinChanged)
ComPort.DataReceived += New System.IO.Ports.SerialDataReceivedEventHandler(port_DataReceived_1)
如何在VB中附加事件处理程序这是奇怪的,现在被拉到其他的东西!
格伦
How do I attach event handlers in VB this is odd, getting pulled to other things now!
Glenn
推荐答案
请参阅此内容以了解如何添加处理程序
http://msdn.microsoft.com/en-us/library/6yyk8z93(v=vs.90).aspx [ ^ ]
Please refer this to understand how to add handlers
http://msdn.microsoft.com/en-us/library/6yyk8z93(v=vs.90).aspx[^]
这里: http://msdn.microsoft.com/en-us/library/7taxzxka.aspx [ ^ ]。
如果某些语法对你来说很奇怪(我可以理解),要么使用这种奇怪的方式,要么切换到对语法更合理的语言。 :-)
为了将来,你可以自己做C#和VB.NET之间的翻译。我提供了有关如何自动完成此操作的全面解释。离线方法(使用ILSpy)是最可靠的,并为您提供非常好的质量。请查看我过去的答案:
需要将vb代码转换为c# [ ^ ],
代码解释,C#到VB.NET [ ^ ]。
-SA
Here: http://msdn.microsoft.com/en-us/library/7taxzxka.aspx[^].
If some syntax seems odd to you (which I can understand), either use this odd way, or switch to the language which looks more syntactically reasonable to you. :-)
For future, do such a routine thing as translations between C# and VB.NET by yourself. I provided comprehensive explanations on how to do that automatically. And the off-line approach (using ILSpy) is the most reliable and gives you very good quality. Please see my past answers:
Need to convert vb code to c#[^],
Code Interpretation, C# to VB.NET[^].
—SA
这篇关于如何将事件处理程序转换为VB Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文