Avatar of r3nder
r3nder
Flag for United States of America asked on

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

Visual Basic.NET.NET ProgrammingASP.NET

Avatar of undefined
Last Comment
r3nder

8/22/2022 - Mon
UnifiedIS

Which line throws the exception?
r3nder

ASKER
14
Éric Moreau

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.
Your help has saved me hundreds of hours of internet surfing.
fblack61
ste5an

Do you think we are human compilers?

But obviously: You cannot execute code outside of a method.
r3nder

ASKER
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

SOLUTION
Éric Moreau

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
ste5an

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
r3nder

ASKER
as always thank you guys
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.