Vb.Net编译错误

时间:2016-02-17 17:30:51

标签: vb.net

当我尝试在调试中运行我的程序时,我一直收到错误BC30456,内容如下:

  

严重级代码描述项目文件行抑制状态   错误BC30456' Form1'不是' serialtest2'的成员。 serialtest2 C:\ Users \ Rhans \ Desktop \ VB6 Programs \ Ethernet Socket \ serialtest2 \ My Project \ Application.Designer.vb 35 Active

我希望监控一个连接了mettler toledo scale的串口,我试图在表单上显示连续的权重......

非常感谢任何帮助。

代码如下:

 Imports System.IO.Ports
Imports System.IO.Ports.SerialPort


Public Class SerialCommunication

    Private WithEvents Port As New SerialPort


    Private Sub SerialCommunication_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        With Port
            .PortName = "COM5"
            .RtsEnable = True
            .BaudRate = 9600
            .Open()
        End With
    End Sub

    Private Sub port_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles Port.DataReceived
        Dim buffer As String = Port.ReadExisting()
        txtDisplay.Text = buffer
    End Sub

2 个答案:

答案 0 :(得分:0)

您的SerialCommunication类用它的外观替换Form1。

转到项目>然后选择“启动表单:串行通信”或“将类名称更改为" Form1"而不是" SerialCommunication"

答案 1 :(得分:0)

我遇到了同样的问题,我的解决方案来自Web.config。我从编译节点中删除了默认语言。当我把它放回去时它工作正常。

<compilation debug="true" defaultLanguage="vb" targetFramework="4.5.2">