Declare Error

  • Thread starter Thread starter David Webb
  • Start date Start date
D

David Webb

Hi,

I found the following snippet of code in a form on the Open NETCF
site. When I add a new class and paste the code, it is having a hiccup
on the Declare word, after Private Shared statement. It says "Shared
is not valid on a Declare". This is probably simple so could someone
please point me in the right direction? I'm hoping this is an easy
solution to play a wave file.

Using VS.NET 2003, CF (VB.NET)

Regards,

David.

Imports System
Imports System.Runtime.InteropServices

Namespace InTheHand

Public Class Sound

Public Shared Sub Play(ByVal FileName As String)
Dim hResult As Integer = PlaySoundW(FileName, 0, 0)
End Sub 'Play

'playsound
Private Shared Declare Function PlaySoundW Lib "coredll.dll"
Alias "PlaySoundW" _
(ByVal lpszName As String, ByVal hModule As Integer, ByVal
dwFlags As Integer) As Integer

End Class 'Sound

End Namespace 'InTheHand
 
"Shared" is implied when using Declare. Remove it from your code below and you should be set.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: (e-mail address removed) (David Webb)
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: Declare Error
| Date: 1 Sep 2003 22:56:08 -0700
| Organization: http://groups.google.com/
| Lines: 35
| Message-ID: <[email protected]>
| NNTP-Posting-Host: 203.25.165.1
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1062482169 8189 127.0.0.1 (2 Sep 2003 05:56:09 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: 2 Sep 2003 05:56:09 GMT
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!
news.tele.dk!small.news.tele.dk!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!postnews1.google.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.compactframework:32497
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hi,
|
| I found the following snippet of code in a form on the Open NETCF
| site. When I add a new class and paste the code, it is having a hiccup
| on the Declare word, after Private Shared statement. It says "Shared
| is not valid on a Declare". This is probably simple so could someone
| please point me in the right direction? I'm hoping this is an easy
| solution to play a wave file.
|
| Using VS.NET 2003, CF (VB.NET)
|
| Regards,
|
| David.
|
| Imports System
| Imports System.Runtime.InteropServices
|
| Namespace InTheHand
|
| Public Class Sound
|
| Public Shared Sub Play(ByVal FileName As String)
| Dim hResult As Integer = PlaySoundW(FileName, 0, 0)
| End Sub 'Play
|
| 'playsound
| Private Shared Declare Function PlaySoundW Lib "coredll.dll"
| Alias "PlaySoundW" _
| (ByVal lpszName As String, ByVal hModule As Integer, ByVal
| dwFlags As Integer) As Integer
|
| End Class 'Sound
|
| End Namespace 'InTheHand
|
 
Back
Top