Question : Convert C# to VB

Ive been trying to convert some c# code from 'http://www.c-sharpcorner.com/UploadFile/nipuntomar/FileUploadsilverlight03182009030537AM/FileUploadsilverlight.aspx' however having issues with the section:-
            c.OpenWriteCompleted += (sender, e) =>
            {
                PushData(data, e.Result);
                e.Result.Close();
                data.Close();
            };

My latest attempt was to run it through a code conversion tool at http://www.developerfusion.com/tools/convert/csharp-to-vb/, but still produces errors most of which I fixed, but still have the bit above.

I have tried using the raiseevent code, but it just tells me end of statment expected :-(

Any ideas?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
Imports System.IO
Imports System
Imports System.Net

Partial Public Class MainPage
    Inherits UserControl

    Public Sub New()
        InitializeComponent()
    End Sub
    Private Sub UploadFile(ByVal fileName As String, ByVal data As Stream)
        Dim ub As New UriBuilder("http://localhost:3840/receiver.ashx")
        ub.Query = String.Format("filename={0}", fileName)
        Dim c As New WebClient
 	c.OpenWriteCompleted += Function(sender, e) Do
        PushData(data, e.Result)
        e.Result.Close()
        data.Close()
    End Sub
	c.OpenWriteAsync(ub.Uri)
End Sub

    Private Sub PushData(ByVal input As Stream, ByVal output As Stream)
        Dim buffer As Byte() = New Byte(4095) {}
        Dim bytesRead As Integer

        While (InlineAssignHelper(bytesRead, input.Read(buffer, 0, buffer.Length))) <> 0
            output.Write(buffer, 0, bytesRead)
        End While
    End Sub
End Class

Answer : Convert C# to VB

If you want to do "inline" then I think it should be:
1:
2:
3:
4:
5:
6:
        Dim c As New WebClient
        AddHandler c.OpenWriteCompleted, Sub(sender, e)
                                             PushData(data, e.Result)
                                             e.Result.Close()
                                             data.Close()
                                         End Sub
Random Solutions  
 
programming4us programming4us