What is the equivalent VB.net for this C code?
-
Not sure if this is best forum but... I am trying to convert somebody elses old C component into a VB.NET version and in the process add some more functionality. Silly me... I don't know any C at all but having an educated guess. This following bit has me stumped. Can anybody help with the conversion.
protected void onMenuItemClick(Object sender, EventArgs e) { MenuItem item = (MenuItem)sender; if (MRUItemClicked != null) { string fileName = (string)_itemMap[item]; MRUItemClicked(this, new MRUItemClickedEventArgs(fileName)); } }
Cheers Tim -
Not sure if this is best forum but... I am trying to convert somebody elses old C component into a VB.NET version and in the process add some more functionality. Silly me... I don't know any C at all but having an educated guess. This following bit has me stumped. Can anybody help with the conversion.
protected void onMenuItemClick(Object sender, EventArgs e) { MenuItem item = (MenuItem)sender; if (MRUItemClicked != null) { string fileName = (string)_itemMap[item]; MRUItemClicked(this, new MRUItemClickedEventArgs(fileName)); } }
Cheers TimThis is obviously not C code, do you mean C# ? This code is C#. This is an event handler for a menu item click. It converts the senser to a MenuItem, which is what it is. MRUItemClicked is obviously a member variable, null is called Nothing from memory in VB land. _itemMap is obviously a dictionary/hash table member variable. MRUItemClicked appears to be a delegate. Which of those things do you not understand ? Do you know what a delegate is ? I assume you have _itemMap set up from converting the rest of the code ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Not sure if this is best forum but... I am trying to convert somebody elses old C component into a VB.NET version and in the process add some more functionality. Silly me... I don't know any C at all but having an educated guess. This following bit has me stumped. Can anybody help with the conversion.
protected void onMenuItemClick(Object sender, EventArgs e) { MenuItem item = (MenuItem)sender; if (MRUItemClicked != null) { string fileName = (string)_itemMap[item]; MRUItemClicked(this, new MRUItemClickedEventArgs(fileName)); } }
Cheers TimProbably this:
Protected Sub onMenuItemClick(ByVal sender As Object, ByVal e As EventArgs) Dim item As MenuItem = CType(sender,MenuItem) If (Not (MRUItemClicked) Is Nothing) Then Dim fileName As String = CType(_itemMap(item),String) MRUItemClicked(Me, New MRUItemClickedEventArgs(fileName)) End If End Sub
Best Regards, Apurva Kaushal