Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8801973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:58:12+00:00 2026-06-14T00:58:12+00:00

I am trying to convert some C# code to VB .Net and am having

  • 0

I am trying to convert some C# code to VB .Net and am having issues with some of the delgate conversions.

BackupLibraries.cs

Public Class Backup
{
public event EventHandler<BackupPEventArgs> Backup;

...
if (BackupProgress != null) BackupProgress(this, new BackupProgressEventArgs(percent_complete))
...
}

public class BackupEventArgs : EventArgs
    {
        private float percentage;

        public BackupProgressEventArgs(float percentage)
        {
            this.percentage = percentage;
        }

        public float Percentage
        {
            get { return percentage; }
        }
    }

UnitTest.cs

public void BackupTest()
{
Backup bu = new Backup()
        bu.BackupProgress += delegate(object sender, Backup.BackupEventArgs e)

        {
            Debug.WriteLine("Percentage: " + e.Percentage.ToString());
        };
}

It’s converting sb.Backup += delegate(object sender, SQLBackup.BackupProgressEventArgs e)
and wiring it to the event in the other class I am having issues on.

In VB:

Backuplibraries.vb

Public Class Backup

Public Event Backup As EventHandler(Of BackupEventArgs)

...
RaiseEvent Backup(Me, New BackupEventArgs(percent_complete))
...
End Class

Public Class BackupEventArgs
            Inherits EventArgs

UnitTest.vb

Public Class BackupTest

Dim bu As New Backup()

bu.BackupProgress = Sub(sender As Object, e As BackupEventArgs)
                         Debug.WriteLine(e.Percentage.ToString())
                         End Sub

End Class

Of course

bu.BackupProgress = Sub(sender As Object, e As BackupEventArgs)
                             Debug.WriteLine(e.Percentage.ToString())
                             End Sub

is where the issue I am having with the conversion from C# to .Net is.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:58:13+00:00Added an answer on June 14, 2026 at 12:58 am

    You might try AddHandler here

    AddHandler bu.BackupProgress, AddressOf Sub(sender As Object, e As BackupEventArgs)
                             Debug.WriteLine(e.Percentage.ToString())
                             End Sub
    

    To have the arguments come in, this would not be able to remain anonymous in this fashion in VB.Net. You would need to abstract out your method with a fixed address.

    Protected Sub BackupProgressDelegate(sender as Object, e as BackupEventArgs)
        Debug.WriteLine(e.Percentage.ToString())
    End Sub
    
    ...
    
    AddHandler bu.BackupProgress, AddressOf BackupProgressDelegate
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert some VB.net code into C# and having issues trying to
I am trying to convert some old VB6 code to VB.NET. The VB6 uses
I am trying to refactor some code in an ASP.Net website and having a
I was trying to convert some C# code to Vb.net but there was a
I have some C# code I'm trying to convert to VB.NET. There are some
I'm trying to convert some C# code to VB.NET. I have the following in
I'm trying to convert some code from Richfaces 4 showcase to use CDI instead
Background : I'm trying to convert some JavaScript code which uses the the Crossfilter
There is some code that I'm trying to convert from IList to IEnumerable :
I am trying to convert an SVN repository to Mercurial, but I'm having some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.