[RESOLVED] C# to VB.NET conversion
Hi, I'm currently converting some code from C#.NET to VB.NET
I'm having a problem with converting this code:
private const string mmdll = "winmm.dll";
[DllImport(mmdll)]
public static extern int waveOutGetNumDevs();
[DllImport(mmdll)]
public static extern int waveOutPrepareHeader(IntPtr hWaveOut, ref WaveHdr lpWaveOutHdr, int uSize);
This got converted to VB.NET:
Private Const mmdll As String = "winmm.dll"
<DllImport(mmdll)>
Public Shared Function waveOutGetNumDevs() As Integer
End Function
<DllImport(mmdll)>
Public Shared Function waveOutPrepareHeader(ByVal hWaveOut As IntPtr, ByRef lpWaveOutHdr As WaveHdr, ByVal uSize As Integer) As Integer
End Function
But I get an error on <DllImport(mmdll)>:
"Attribute Specifier is not a complete statement. Use a line continuation to apply the attribute to the following statement"
Please advice
Re: C# to VB.NET conversion
An invaluable converter utility that is free but converts up to 100 lines of code at a time.
http://www.tangiblesoftwaresolutions...Instant_VB.htm
Re: C# to VB.NET conversion
You need to place an underscore (line continuation) after the attribute, just as the error message states. C# lines end with a semicolon; VB.NET lines end with a newline. So you either need to do this:
Code:
<DllImport(mmdll)> _
Public Shared Function waveOutGetNumDevs() As Integer
or this:
Code:
<DllImport(mmdll)> Public Shared Function waveOutGetNumDevs() As Integer
Also, I think the "End Function" is not required, but I don't know much about the VB.NET syntax.
Re: C# to VB.NET conversion
End Function is requiredbut also the EntryPoint:= argument too.
vb Code:
<DllImport("mmdll.dll", EntryPoint:="waveOutGetNumDevs")> _
Public Shared Function waveOutGetNumDevs() As Integer
End Function
Also, in addition to the converter utilities you can dopwnload the API Viewer Utility (link in my signature). It has the various formats for API definitions. ;)
Re: C# to VB.NET conversion
okay thanks, that solves it