I’m having trouble converting a C# delegate to VB.NET.
How can this be done?
public MainForm()
{
InitializeComponent();
_twain = new Twain(new WinFormsWindowMessageHook(this));
_twain.TransferImage += delegate(Object sender, TransferImageEventArgs args)
{
if (args.Image != null)
{
pictureBox1.Image = args.Image;
widthLabel.Text = "Width: " + pictureBox1.Image.Width;
heightLabel.Text = "Height: " + pictureBox1.Image.Height;
}
};
_twain.ScanningComplete += delegate
{
Enabled = true;
};
}
Neither of those methods seem to use any context in the constructor itself, so I would convert each anonymous method into a “normal” method in your VB code (which should be straightforward), and then use something like this in your constructor:
The methods should have the same signature as the events they’re handling.