Help with C# to VB.Net Conversion

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?RGFuaWVsIEplZmZyZXk=?=

    Help with C# to VB.Net Conversion

    Hello,
    I am a C# developer and am now starting to do some work in VB.NET and for
    the life of me cant get something working the way I cant.

    If anyone can offer any suggestions on how to convert this c# into Working
    VB.Net code that would be great.

    C# Class to be converted to VB.Net

    I cant seem to get this line to work FireAsync(Compl eted, this,
    EventArgs.Empty );


    Class........

    public event EventHandler Completed;
    ...
    ...
    ...
    private void someMethod()
    {
    FireAsync(Compl eted, this, EventArgs.Empty );
    }


    protected void FireAsync(Deleg ate dlg, params object[] pList)
    {
    if (dlg != null)
    {
    Target.BeginInv oke(dlg, pList);
    }
    }

    end class



    VB.Net calling Code

    Public MustInherit Class GridData
    Inherits AsyncUtilities. AsyncOperation

    AddHandler mobjData.Comple ted, AddressOf DataLoad_Finish ed
    AddHandler mobjData.Cancel led, AddressOf DataLoad_Cancel led
    AddHandler mobjData.Failed , New
    System.Threadin g.ThreadExcepti onEventHandler( AddressOf DataLoad_Failed )
  • Andy B

    #2
    Re: Help with C# to VB.Net Conversion

    Telerik Code Converter by Progress is free online code converter from C# to VB and from VB to C#. No registration required. Check it out.



    "Daniel Jeffrey" <DanielJeffrey@ discussions.mic rosoft.comwrote in message
    news:2B62AA33-42D3-4723-AC10-8A9EF6D719F7@mi crosoft.com...
    Hello,
    I am a C# developer and am now starting to do some work in VB.NET and for
    the life of me cant get something working the way I cant.
    >
    If anyone can offer any suggestions on how to convert this c# into Working
    VB.Net code that would be great.
    >
    C# Class to be converted to VB.Net
    >
    I cant seem to get this line to work FireAsync(Compl eted, this,
    EventArgs.Empty );
    >
    >
    Class........
    >
    public event EventHandler Completed;
    ...
    ...
    ...
    private void someMethod()
    {
    FireAsync(Compl eted, this, EventArgs.Empty );
    }
    >
    >
    protected void FireAsync(Deleg ate dlg, params object[] pList)
    {
    if (dlg != null)
    {
    Target.BeginInv oke(dlg, pList);
    }
    }
    >
    end class
    >
    >
    >
    VB.Net calling Code
    >
    Public MustInherit Class GridData
    Inherits AsyncUtilities. AsyncOperation
    >
    AddHandler mobjData.Comple ted, AddressOf DataLoad_Finish ed
    AddHandler mobjData.Cancel led, AddressOf DataLoad_Cancel led
    AddHandler mobjData.Failed , New
    System.Threadin g.ThreadExcepti onEventHandler( AddressOf DataLoad_Failed )

    Comment

    • =?Utf-8?B?RGFuaWVsIEplZmZyZXk=?=

      #3
      Re: Help with C# to VB.Net Conversion

      This produces the same result I got when I did it myself

      'Public Event Completed(sende r As Object, e As System.EventArg s)' is an
      event, and cannot be called directly. Use a 'RaiseEvent' statement to raise
      an event.


      "Andy B" wrote:
      Telerik Code Converter by Progress is free online code converter from C# to VB and from VB to C#. No registration required. Check it out.

      >
      >
      "Daniel Jeffrey" <DanielJeffrey@ discussions.mic rosoft.comwrote in message
      news:2B62AA33-42D3-4723-AC10-8A9EF6D719F7@mi crosoft.com...
      Hello,
      I am a C# developer and am now starting to do some work in VB.NET and for
      the life of me cant get something working the way I cant.

      If anyone can offer any suggestions on how to convert this c# into Working
      VB.Net code that would be great.

      C# Class to be converted to VB.Net

      I cant seem to get this line to work FireAsync(Compl eted, this,
      EventArgs.Empty );


      Class........

      public event EventHandler Completed;
      ...
      ...
      ...
      private void someMethod()
      {
      FireAsync(Compl eted, this, EventArgs.Empty );
      }


      protected void FireAsync(Deleg ate dlg, params object[] pList)
      {
      if (dlg != null)
      {
      Target.BeginInv oke(dlg, pList);
      }
      }

      end class



      VB.Net calling Code

      Public MustInherit Class GridData
      Inherits AsyncUtilities. AsyncOperation

      AddHandler mobjData.Comple ted, AddressOf DataLoad_Finish ed
      AddHandler mobjData.Cancel led, AddressOf DataLoad_Cancel led
      AddHandler mobjData.Failed , New
      System.Threadin g.ThreadExcepti onEventHandler( AddressOf DataLoad_Failed )
      >
      >
      >

      Comment

      • Armin Zingler

        #4
        Re: Help with C# to VB.Net Conversion

        "Daniel Jeffrey" <DanielJeffrey@ discussions.mic rosoft.comschri eb
        This produces the same result I got when I did it myself
        >
        'Public Event Completed(sende r As Object, e As System.EventArg s)' is an
        event, and cannot be called directly. Use a 'RaiseEvent' statement to
        raise
        an event.
        VB does something under the hood. The implicitly declared delegate is called
        CompletedEventH andler and the instance is called CompletedEvent. So, try
        passing 'CompletedEvent ', not 'Completed', if a Delegate is expected.
        Untested.


        Armin


        Comment

        • Daniel Jeffrey

          #5
          Re: Help with C# to VB.Net Conversion

          thanks this worked.

          Who ever said C# and VB.Net are "fundamenta lly" the same, never moved from 1
          to the other

          Dan

          "Armin Zingler" <az.nospam@free net.dewrote in message
          news:eBE8D8jOJH A.1144@TK2MSFTN GP05.phx.gbl...
          "Daniel Jeffrey" <DanielJeffrey@ discussions.mic rosoft.comschri eb
          >This produces the same result I got when I did it myself
          >>
          >'Public Event Completed(sende r As Object, e As System.EventArg s)' is an
          >event, and cannot be called directly. Use a 'RaiseEvent' statement to
          >raise
          >an event.
          >
          VB does something under the hood. The implicitly declared delegate is
          called
          CompletedEventH andler and the instance is called CompletedEvent. So, try
          passing 'CompletedEvent ', not 'Completed', if a Delegate is expected.
          Untested.
          >
          >
          Armin
          >
          >

          Comment

          • Cor Ligthert[MVP]

            #6
            Re: Help with C# to VB.Net Conversion

            Daniel,

            You are translating code not converting.

            In VB.Net there is the easy keyword WithEvents, try that as you convert,
            instead of difficult ways as it has to be done in C# which can be easily
            done in VB for Net.



            Cor

            "Daniel Jeffrey" <DanielJeffrey@ discussions.mic rosoft.comwrote in message
            news:2B62AA33-42D3-4723-AC10-8A9EF6D719F7@mi crosoft.com...
            Hello,
            I am a C# developer and am now starting to do some work in VB.NET and for
            the life of me cant get something working the way I cant.
            >
            If anyone can offer any suggestions on how to convert this c# into Working
            VB.Net code that would be great.
            >
            C# Class to be converted to VB.Net
            >
            I cant seem to get this line to work FireAsync(Compl eted, this,
            EventArgs.Empty );
            >
            >
            Class........
            >
            public event EventHandler Completed;
            ...
            ...
            ...
            private void someMethod()
            {
            FireAsync(Compl eted, this, EventArgs.Empty );
            }
            >
            >
            protected void FireAsync(Deleg ate dlg, params object[] pList)
            {
            if (dlg != null)
            {
            Target.BeginInv oke(dlg, pList);
            }
            }
            >
            end class
            >
            >
            >
            VB.Net calling Code
            >
            Public MustInherit Class GridData
            Inherits AsyncUtilities. AsyncOperation
            >
            AddHandler mobjData.Comple ted, AddressOf DataLoad_Finish ed
            AddHandler mobjData.Cancel led, AddressOf DataLoad_Cancel led
            AddHandler mobjData.Failed , New
            System.Threadin g.ThreadExcepti onEventHandler( AddressOf DataLoad_Failed )

            Comment

            • Andy B

              #7
              Re: Help with C# to VB.Net Conversion

              Yea. I found problems with that converter now that I looked at it. I
              converted some base classes for custom providers and it broke the code.


              "Daniel Jeffrey" <DanielJeffrey@ discussions.mic rosoft.comwrote in message
              news:F5DB6A2D-D8AB-4441-A81E-DBE996D7509B@mi crosoft.com...
              This produces the same result I got when I did it myself
              >
              'Public Event Completed(sende r As Object, e As System.EventArg s)' is an
              event, and cannot be called directly. Use a 'RaiseEvent' statement to
              raise
              an event.
              >
              >
              "Andy B" wrote:
              >
              >http://converter.telerik.com/
              >>
              >>
              >"Daniel Jeffrey" <DanielJeffrey@ discussions.mic rosoft.comwrote in
              >message
              >news:2B62AA3 3-42D3-4723-AC10-8A9EF6D719F7@mi crosoft.com...
              Hello,
              I am a C# developer and am now starting to do some work in VB.NET and
              for
              the life of me cant get something working the way I cant.
              >
              If anyone can offer any suggestions on how to convert this c# into
              Working
              VB.Net code that would be great.
              >
              C# Class to be converted to VB.Net
              >
              I cant seem to get this line to work FireAsync(Compl eted, this,
              EventArgs.Empty );
              >
              >
              Class........
              >
              public event EventHandler Completed;
              ...
              ...
              ...
              private void someMethod()
              {
              FireAsync(Compl eted, this, EventArgs.Empty );
              }
              >
              >
              protected void FireAsync(Deleg ate dlg, params object[] pList)
              {
              if (dlg != null)
              {
              Target.BeginInv oke(dlg, pList);
              }
              }
              >
              end class
              >
              >
              >
              VB.Net calling Code
              >
              Public MustInherit Class GridData
              Inherits AsyncUtilities. AsyncOperation
              >
              AddHandler mobjData.Comple ted, AddressOf
              DataLoad_Finish ed
              AddHandler mobjData.Cancel led, AddressOf
              DataLoad_Cancel led
              AddHandler mobjData.Failed , New
              System.Threadin g.ThreadExcepti onEventHandler( AddressOf DataLoad_Failed )
              >>
              >>
              >>

              Comment

              Working...