Hi I am looking at a tutorial which uses the camera and I came accross some methods that I need. Only problem is that they are in C# and I need them to be in VB. I have used a converter but it doesnt convert it properly.
private void VideoCamera_Initialized(object sender, object eventArgs)
{
if (Initialized != null)
{
Initialized.Invoke(this, new EventArgs());
}
}
public bool LampEnabled
{
get { return (bool)_videoCameraLampEnabledPropertyInfo.GetGetMethod().Invoke(_videoCamera, new object[0]); }
set { _videoCameraLampEnabledPropertyInfo.GetSetMethod().Invoke(_videoCamera, new object[] { value }); }
}
Here is the converted code and the errors:
Private Sub VideoCamera_Initialized(sender As Object, eventArgs As Object)
If Initialized IsNot Nothing Then
Initialized.Invoke(Me, New EventArgs())
End If
End Sub
Public Property LampEnabled() As Boolean
Get
Return CBool(_videoCameraLampEnabledPropertyInfo.GetGetMethod().Invoke(_videoCamera, New Object(-1) {}))
End Get
Set(value As Boolean)
_videoCameraLampEnabledPropertyInfo.GetSetMethod().Invoke(_videoCamera, New Object() {value})
End Set
End Property
Errors:
Error 2 ‘Public Event Initialized(sender As Object, e As System.EventArgs)’ is an event, and cannot be called directly. Use a ‘RaiseEvent’ statement to raise an event.
In terms of the second method. It doesnt look like its been converted properly even though there isnt any errors
As the error states, you need to use
RaiseEvent; code converters don’t know if it is, in fact, an event, or if it’s a delegate. And, of course, since VB.NET is an amazing language, you don’t need theIs Nothingcheck or theNew Object(-1) {}, or theNew Object()part before{value}.