Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
after convering my code from c# to vb.net, this code gives me an error
 

Private Sub VoiceRoom_Load(sender As Object, e As EventArgs)
            sound = New DirectSoundHelper()
            sound.OnBufferFulfill += New EventHandler(SendVoiceBuffer)
        End Sub
 

OnBufferFulfill is an event
Posted 18-Nov-12 7:22am
muleta305
Comments
Sergey Alexandrovich Kryukov at 18-Nov-12 14:02pm
   
What error? It's not nice to ask about an error without showing comprehensive error information.
Also, explain your ultimate goal. What do you want to do with the sound? What's your application type?
--SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Event is not called, its is invoked. Invocation is the mechanism when the event instance lists all the item in the event invocation list and invokes each of the items, and the item is a single-case delegate instance; this way, all the handlers of the event get called.
 
The important limitation of this mechanism is that the invocation can only be done in the class where the even is declared, nowhere else, not even in a derived class. This is done via a call to event instance's Invoke method.
 
Your code is not trying to invoke the event; and you probably never need it. You only need to invoke event you declare in your own class or structure. In your code, you are trying to add a handler to an event instance. First of all, the handler type should match appropriate delegate type. I don't know what is the type DirectSoundHelper, so you need to find out appropriate delegate type for the event. First of all, learn how to work with events in VB.NET:
http://msdn.microsoft.com/en-us/library/ms973905.aspx[^],
http://msdn.microsoft.com/en-us/library/ms172877%28v=vs.80%29.aspx[^].
 
This is a short CodeProject article: Step by Step: Event handling in VB.NET[^].
 
Also, I doubt you really need any Direct Sound wrapper; usually .NET along is enough. But it depends on your purpose you did not share with us. That's why it's very important to start your questions with explanations of your ultimate goals.
 
—SA
  Permalink  
Comments
Nelek at 18-Nov-12 16:58pm
   
OP Comment to you moved here from non solution below
thanks a lot ,that example has helped me, am trying to develop a voice chat application,i found one but it was in c# ,so i converted the code to vb.net and part kept giving me an error
Sergey Alexandrovich Kryukov at 18-Nov-12 18:37pm
   
@muleta:
Great. You are welcome.
Good luck, call again.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.141022.1 | Last Updated 18 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100