How to do this in VB.NET?
-
23-02-2021 - |
Frage
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);
}
}
Lösung
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)
Andere Tipps
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
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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow