1

i having problem in converting this C# code into VB.net. The loadLecturer seem to be having problem after convert to VB.NET

VB code just afterInitializeComponent()

context.Load(context.GetLecturesQuery(), LoadLecturer, Nothing)

The C# code i wish to convert and debug

private void LoadLecturer(LoadOperation<tblLecturer> obj)
{
    foreach (var item in obj.Entities)
    {
        cbLID.Items.Add(item.lecturerID + " - " + item.lfirstName + " " + item.llastName);
    }
}
Nikhil Agrawal
  • 47,018
  • 22
  • 121
  • 208
Carson Lee
  • 2,673
  • 3
  • 20
  • 23
  • 2
    And which aspect of that are you having problems with? – Jon Skeet Nov 08 '11 at 07:38
  • Error 1 Argument not specified for parameter 'obj' of 'Private Sub LoadLecturer(obj As System.ServiceModel.DomainServices.Client.LoadOperation(Of Web.Lecture))'. C:\Users\Carson\documents\visual studio 2010\Projects\LotusUniversity\LotusUniversity\Views\Home.xaml.vb 13 50 LotusUniversity – Carson Lee Nov 08 '11 at 07:42
  • From this line context.Load(context.GetLecturesQuery(), LoadLecturer, Nothing) – Carson Lee Nov 08 '11 at 07:42

3 Answers3

3

Given the comment, it sounds like it's not the method itself which is causing you grief, but how you call it - because in the original code you're using a method group conversion. I suspect it's as simple as:

context.Load(context.GetLecturesQuery(), AddressOf LoadLecturer, Nothing)
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
1

Following this link for the VB.NET converter this is what I am getting :)

Private Sub LoadLecturer(obj As LoadOperation(Of tblLecturer))
For Each item As var In obj.Entities
    cbLID.Items.Add(Convert.ToString(item.lecturerID) & " - " & Convert.ToString(item.lfirstName) & " " & Convert.ToString(item.llastName))
Next
End Sub
Dimi Takis
  • 4,924
  • 3
  • 29
  • 41
0
Private Sub LoadLecturer(obj As LoadOperation(Of tblLecturer))
    For Each item As var In obj.Entities
        cbLID.Items.Add(Convert.ToString(item.lecturerID) & " - " & Convert.ToString(item.lfirstName) & " " & Convert.ToString(item.llastName))
    Next
End Sub
Raoul George
  • 2,807
  • 1
  • 21
  • 25