Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. What is the VB.NET equivalent of this code?

What is the VB.NET equivalent of this code?

Scheduled Pinned Locked Moved C#
csharpquestionhelpannouncement
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TJO1
    wrote on last edited by
    #1

    Not sure if this is best forum but... I am trying to convert some old C# code 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 or give an indication of what his code is doing? protected void onMenuItemClick(Object sender, EventArgs e) { MenuItem item = (MenuItem)sender; if (MyItemClicked != null) { string fileName = (string)_itemMap[item]; MyItemClicked(this, new MyItemClickedEventArgs(fileName)); } } Cheers Tim

    F E D 3 Replies Last reply
    0
    • T TJO1

      Not sure if this is best forum but... I am trying to convert some old C# code 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 or give an indication of what his code is doing? protected void onMenuItemClick(Object sender, EventArgs e) { MenuItem item = (MenuItem)sender; if (MyItemClicked != null) { string fileName = (string)_itemMap[item]; MyItemClicked(this, new MyItemClickedEventArgs(fileName)); } } Cheers Tim

      F Offline
      F Offline
      farshad A
      wrote on last edited by
      #2

      Hi I'm not much familiar with vb, but the equivalent for this code in vb should be something like this: Private Sub MenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem.Click Dim item As MenuItem If Not MyItemClicked Is Nothing Then Dim filename As String filename = _itemMap(item).ToString() MyItemClicked(Me, New MyItemClickedEventArgs(filename)) End If End Sub if you need, I can explain what this method does, and then you can write the correct code yourself. HTH farshad

      1 Reply Last reply
      0
      • T TJO1

        Not sure if this is best forum but... I am trying to convert some old C# code 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 or give an indication of what his code is doing? protected void onMenuItemClick(Object sender, EventArgs e) { MenuItem item = (MenuItem)sender; if (MyItemClicked != null) { string fileName = (string)_itemMap[item]; MyItemClicked(this, new MyItemClickedEventArgs(fileName)); } } Cheers Tim

        E Offline
        E Offline
        Ed Poore
        wrote on last edited by
        #3

        This would have been more suited to the VB forum.

        As of how to accomplish that have you ever tried Google? Failing that try :badger::badger::badger:.

        1 Reply Last reply
        0
        • T TJO1

          Not sure if this is best forum but... I am trying to convert some old C# code 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 or give an indication of what his code is doing? protected void onMenuItemClick(Object sender, EventArgs e) { MenuItem item = (MenuItem)sender; if (MyItemClicked != null) { string fileName = (string)_itemMap[item]; MyItemClicked(this, new MyItemClickedEventArgs(fileName)); } } Cheers Tim

          D Offline
          D Offline
          Dave Doknjas
          wrote on last edited by
          #4

          The first reply was close...but no cigar. VB equivalents regarding events can be tricky. You'll need (especially note the hidden "MyItemClickedEvent" variable): Private Sub MenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem.Click Dim item As MenuItem If Not MyItemClickedEvent Is Nothing Then Dim filename As String filename = _itemMap(item).ToString() RaiseEvent MyItemClicked(Me, New MyItemClickedEventArgs(filename)) End If End Sub

          David Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: C# to C++ converter, VB to C++ converter Clear VB: Cleans up VB.NET code C# Code Metrics: Quick metrics for C#

          T 2 Replies Last reply
          0
          • D Dave Doknjas

            The first reply was close...but no cigar. VB equivalents regarding events can be tricky. You'll need (especially note the hidden "MyItemClickedEvent" variable): Private Sub MenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem.Click Dim item As MenuItem If Not MyItemClickedEvent Is Nothing Then Dim filename As String filename = _itemMap(item).ToString() RaiseEvent MyItemClicked(Me, New MyItemClickedEventArgs(filename)) End If End Sub

            David Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: C# to C++ converter, VB to C++ converter Clear VB: Cleans up VB.NET code C# Code Metrics: Quick metrics for C#

            T Offline
            T Offline
            TJO1
            wrote on last edited by
            #5

            Thanks for your responses. This now makes sense to me, it was just a syntax issue. Cheers Tim

            1 Reply Last reply
            0
            • D Dave Doknjas

              The first reply was close...but no cigar. VB equivalents regarding events can be tricky. You'll need (especially note the hidden "MyItemClickedEvent" variable): Private Sub MenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem.Click Dim item As MenuItem If Not MyItemClickedEvent Is Nothing Then Dim filename As String filename = _itemMap(item).ToString() RaiseEvent MyItemClicked(Me, New MyItemClickedEventArgs(filename)) End If End Sub

              David Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: C# to C++ converter, VB to C++ converter Clear VB: Cleans up VB.NET code C# Code Metrics: Quick metrics for C#

              T Offline
              T Offline
              TJO1
              wrote on last edited by
              #6

              David, On further examination of your response, does the following (second line of original code) assign a value to item? MenuItem item = (MenuItem)sender; If so, this assignment is missing from your response. After the = is what I am struggling with. Cheers Tim

              D 1 Reply Last reply
              0
              • T TJO1

                David, On further examination of your response, does the following (second line of original code) assign a value to item? MenuItem item = (MenuItem)sender; If so, this assignment is missing from your response. After the = is what I am struggling with. Cheers Tim

                D Offline
                D Offline
                Dave Doknjas
                wrote on last edited by
                #7

                D'oh! I started with Farshad's response and I just modified it. You should definitely have: Dim item As MenuItem = CType(sender, MenuItem)

                David Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: C# to C++ converter, VB to C++ converter Clear VB: Cleans up VB.NET code C# Code Metrics: Quick metrics for C#

                T 1 Reply Last reply
                0
                • D Dave Doknjas

                  D'oh! I started with Farshad's response and I just modified it. You should definitely have: Dim item As MenuItem = CType(sender, MenuItem)

                  David Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: C# to C++ converter, VB to C++ converter Clear VB: Cleans up VB.NET code C# Code Metrics: Quick metrics for C#

                  T Offline
                  T Offline
                  TJO1
                  wrote on last edited by
                  #8

                  NOW I get it Thanks David

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups