请教:关于动态创建Port 端口控件提示“不具有相同签名”的问题

异想天开的妄想狂 异想天开的妄想狂 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
各位大侠:

我最近在写一个程序用到System.IO.Ports.SerialPort 控件,因为程序中多个端口可以使用,由用户来选择哪几个,那么我想把端口控件设置为动态创建的,这样,程序在运行中侦测到用户选择了几个端口,那么就可以动态相应的生成几个,于是在触发的事件里我是这么声明的

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim DutPort_Test As System.IO.Ports.SerialPort = New System.IO.Ports.SerialPort
AddHandler DutPort_Test.DataReceived, AddressOf onDataReceived_Test
...................其他代码省略

End Sub

Private Sub onDataReceived_Test(ByVal Source As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs)
Invoke(New DataReceivedEventHandler(AddressOf DutPort_Test_DataReceived), Source, e)
End Sub

Public Sub DutPort_Test_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs)
...................其他代码省略
End Sub

红色字体报错:
Error 4 Method 'Public Sub DutPort_Test_DataReceived(sender As Object, e As System.IO.Ports.SerialDataReceivedEventArgs)' does not have the same signature as delegate 'Delegate Sub DataReceivedEventHandler(sender As Object, e As System.Diagnostics.DataReceivedEventArgs)'. D:\Work_File\QA_Life_Test_VB\QA_Life_Test_VB\UI\Testing.vb 1053 55 QA_Life_Test_VB

请教如何解决这个问题?先谢谢了!

...全文
评论 1
收藏 已收藏
分享
返回顶部
异想天开的妄想狂
VB 16,718 成员 110,520 内容