Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2007

Tip: Looking for answers? Try searching our database.

lost in translation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rodchar - 31 Oct 2007 14:26 GMT
hey all,

could someone please help me translate the following c# snippet:

  public event EventHandler BubbleClick;
  protected void OnBubbleClick(EventArgs e)
  {
     if(BubbleClick != null)
     {
        BubbleClick(this, e);
     }
  }        
i'm particularly having problems with the if statement.

thanks,
rodchar
David Anton - 31 Oct 2007 14:47 GMT
(via Instant VB):
Public Event BubbleClick As EventHandler
Protected Sub OnBubbleClick(ByVal e As EventArgs)
    If BubbleClickEvent IsNot Nothing Then
        RaiseEvent BubbleClick(Me, e)
    End If
End Sub

However, you do not really need the check against the hidden (nearly
undocumented) VB EventNameEvent variable if all you're doing is calling
RaiseEvent.  RaiseEvent will gracefully handle cases where there are no
subscribers to the event.
Signature

http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
C++ to C++/CLI
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB or C# to C++/CLI

> hey all,
>
[quoted text clipped - 12 lines]
> thanks,
> rodchar
cfps.Christian - 31 Oct 2007 14:48 GMT
> hey all,
>
[quoted text clipped - 12 lines]
> thanks,
> rodchar

C# doesn't call the event handler unless it is assigned.

So I think it should read in VB

protected sub OnBubbleClick(byval e as eventargs)
    raiseevent bubbleclick(this, e)
end sub
Lloyd Sheen - 31 Oct 2007 14:59 GMT
> hey all,
>
[quoted text clipped - 12 lines]
> thanks,
> rodchar

Try out this site.  It works great for going back and forth between C# and
VB.NET

http://codeconverter.sharpdevelop.net/SnippetConverter.aspx
rodchar - 31 Oct 2007 17:25 GMT
thanks everyone for the insight and resource. i appreciate it very much.
rod.

> hey all,
>
[quoted text clipped - 12 lines]
> thanks,
> rodchar

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.