|
-
Mar 3rd, 2007, 03:42 PM
#1
Thread Starter
New Member
[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
-
Mar 3rd, 2007, 03:45 PM
#2
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 3rd, 2007, 04:09 PM
#3
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.
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Mar 3rd, 2007, 04:13 PM
#4
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 3rd, 2007, 05:57 PM
#5
Thread Starter
New Member
Re: C# to VB.NET conversion
okay thanks, that solves it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|