Declaration expected Vb.net

I have an error declaration expected
Public Class FINDEMPPINEventArgs
    Inherits System.EventArgs
    ' Dim mode As modExtensions = New modExtensions()
    'Dim cv As cVerifone = New cVerifone()
    Public Property cMx900Series1 As Object = New cMx900Series()
    Public Property cVerifone1 As Object = New cVerifone()
End Class
Public Class Sender
    Public Event Start(ByVal sender As Object, ByVal e As FINDEMPPINEventArgs)
    Protected Overridable Sub OnStart(ByVal e As FINDEMPPINEventArgs)
        RaiseEvent Start(Me, e)
    End Sub
    Dim cVerifone1 = New cVerifone()
     cVerifone1.Send("Pin ENTERED", "<STX>XEVT<FS>0<FS>ControlID<FS>ON_KEYPRESS<FS>1<ETX>")<---cVerifone1 has the error
  


End Class
Public Class Receiver
    Friend WithEvents MySender As Sender
    Private Sub MySender_Start(ByVal sender As Object, _
          ByVal e As FINDEMPPINEventArgs) Handles MySender.Start
        getenteredPin()
    End Sub
    Private Sub getenteredPin()
        'cMx900Series = New cMx900Series()
        cMx900Series1.ProcessCommand()
        EMPPINENTERED = cMx900Series1.EMPPINENTERED.ToString()
        MessageBox.Show(EMPPINENTERED.ToString())
    End Sub
    Private Function cVerifone1() As Object

    End Function
    Private Function cMx900Series1() As Object
    End Function

End Class

Open in new window

LVL 6
r3nderAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

UnifiedISCommented:
Which line throws the exception?
r3nderAuthor Commented:
14
Éric MoreauSenior .Net ConsultantCommented:
you are trying to call an instruction (cVerifone1.Send) but you are outside a method, you are at the class level.

you need to create method that will wrap that call.
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

ste5anSenior DeveloperCommented:
Do you think we are human compilers?

But obviously: You cannot execute code outside of a method.
r3nderAuthor Commented:
Did this and it still  needs a declaration on the marked line
Public Class FINDEMPPINEventArgs

    Inherits System.EventArgs
    Public Property sender As Sender = New Sender
    Public Property cMx900Series1 As Object = New cMx900Series()
    Public Property cVerifone1 As Object = New cVerifone()

    Public Sub callToStart()
        sender.gostart()
    End Sub
End Class
Public Class Sender
    Public Property FINDEMPPIN As FINDEMPPINEventArgs = New FINDEMPPINEventArgs()
    Public Shared Event Start(ByVal sender As Object, ByVal e As FINDEMPPINEventArgs)
    Protected Overridable Sub OnStart(ByVal e As FINDEMPPINEventArgs)
        RaiseEvent Start(Me, e)
    End Sub
    Dim cVerifone1 = New cVerifone()
    FINDEMPPIN.callToStart() <--------------------------------------------------------------------HERE FINDEMPPIN
    Public Sub gostart()
        Dim maiform = New MainForm()
        MainForm.Send("Pin EMP_PIN", "<STX>XEVT<FS>0<FS>", "ControlID", "<FS>ON_KEYPRESS<FS>1<ETX>")
    End Sub

End Class
Public Class Receiver
    Friend WithEvents MySender As Sender
    Private Sub MySender_Start(ByVal sender As Object, _
          ByVal e As FINDEMPPINEventArgs) Handles MySender.Start
        getenteredPin()
    End Sub
    Private Sub getenteredPin()
        'cMx900Series = New cMx900Series()
        cMx900Series1.ProcessCommand()
        EMPPINENTERED = cMx900Series1.EMPPINENTERED.ToString()
        MessageBox.Show(EMPPINENTERED.ToString())
    End Sub
    Private Function cVerifone1() As Object
    End Function
    Private Function cMx900Series1() As Object
    End Function
End Class

Open in new window

Éric MoreauSenior .Net ConsultantCommented:
you cannot have code just like this outside method. A class is just like any other file you would have in .Net.
ste5anSenior DeveloperCommented:
You must move it into a method...

Public Class Sender
    Public Property FINDEMPPIN As FINDEMPPINEventArgs = New FINDEMPPINEventArgs()
    Public Shared Event Start(ByVal sender As Object, ByVal e As FINDEMPPINEventArgs)
    Protected Overridable Sub OnStart(ByVal e As FINDEMPPINEventArgs)
        RaiseEvent Start(Me, e)
    End Sub

    Dim cVerifone1 = New cVerifone()

    Public Sub MyNewMagicMethod()
        FINDEMPPIN.callToStart() <--------------------------------------------------------------------HERE FINDEMPPIN
    End Sub

    Public Sub gostart()
        Dim maiform = New MainForm()
        MainForm.Send("Pin EMP_PIN", "<STX>XEVT<FS>0<FS>", "ControlID", "<FS>ON_KEYPRESS<FS>1<ETX>")
    End Sub

End Class

Open in new window


btw, a Dim on class level makes also not that much sense. And gostart is really uninformative name for a method. A good method name is a speaking one. Normally like in natural languages: VerbSubjectObject().

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
r3nderAuthor Commented:
as always thank you guys
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.