Why my custom VB.Net class file is giving an "Expected :Identifier" Error? What's wrong?

prabha_friend

Prabhakaran Karuppaih
Local time
Today, 10:56
Joined
Mar 22, 2009
Messages
970
Code:
Imports System.IO.Ports
Imports System.IO
Public Class Scale
    Private WithEvents SerialPort As New SerialPort()
    Private Const COM_PORT As String = "COM5" ' Change this to your COM port
    Public Sub New()
        ' Constructor logic here if needed
        With SerialPort
            .PortName = COM_PORT
            .BaudRate = 9600
            .ReadTimeout = 1000
            .Parity = Parity.None
            .DataBits = 8
            .StopBits = StopBits.One
        End With
    End Sub
    Public Function ReadScale() As String
        Dim _scaleValue As String
        SerialPort.Open()
        _scaleValue = SerialPort.ReadLine
        SerialPort.Close()
        Return _scaleValue
    End Function
End Class

Code:
Public Sub mac()
dim myScale as New Scale
End Sub

I am getting "Expected Identifier" Error. What's wrong?
 
You don't say which line errors.

Where is Parity declared, and also StopBits?
 
Last edited:
Code:
Public Sub mac()
'
End Sub
Does the code above trigger the same error?
 
Code:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe C:\Users\arrow\source\repos\Gowtham\Scale_Project\bin\Debug\Scale_Project.dll /tlb /codebase
did the Magic
 

Users who are viewing this thread

Back
Top Bottom