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. Visual Basic
  4. How to Call Function of vb.net whose name stored in Database?

How to Call Function of vb.net whose name stored in Database?

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasetutorialquestion
5 Posts 5 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.
  • G Offline
    G Offline
    Guru_yogi
    wrote on last edited by
    #1

    I have created database driven menu in which against each menu item some function name is stored. I want to call function each menu item in vb.net as this function is defined in VB.net. Thanx

    Gurudatta B. Shelke

    C L A 3 Replies Last reply
    0
    • G Guru_yogi

      I have created database driven menu in which against each menu item some function name is stored. I want to call function each menu item in vb.net as this function is defined in VB.net. Thanx

      Gurudatta B. Shelke

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Guru_yogi wrote:

      I have created database driven menu in which against each menu item some function name is stored. I want to call function each menu item in vb.net as this function is defined in VB.net.

      You might want to have a look in the Reflection namespace. Specifically the MethodInfo class.

      Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

      1 Reply Last reply
      0
      • G Guru_yogi

        I have created database driven menu in which against each menu item some function name is stored. I want to call function each menu item in vb.net as this function is defined in VB.net. Thanx

        Gurudatta B. Shelke

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        You can create a database table storing something like: menuname functionname open openfunction new newfunction We can easily retrieved the function name from the database for the menu clicked. After the function name is received by us, we have to use Reflection. I am giving a code sample like this: Sopposing I have a class where the functions are available Public Class Class1 Public Sub openfunction() MsgBox("This is open function") End Sub End Class Then I have a button on the form, I want to call the function using reflection. You have to import System.Reflection namespace the code goes like this: Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim t As Type = GetType(Class1) Dim o As Object = Activator.CreateInstance(t) Dim mi As MethodInfo = t.GetMethod("openfunction") ' U can write the variable which store the methor name in place of openfunction mi.Invoke(o, Nothing) End Sub The code will slightly change when we will be using any reference assembly or resolving the assemblies at runtime. Hope the solution is OK for you.

        1 Reply Last reply
        0
        • G Guru_yogi

          I have created database driven menu in which against each menu item some function name is stored. I want to call function each menu item in vb.net as this function is defined in VB.net. Thanx

          Gurudatta B. Shelke

          A Offline
          A Offline
          akash_omsairam
          wrote on last edited by
          #4

          First create a function like fun1() use this funtion [private\public\sub] fun1 ............ ....... ..... end sub

          D 1 Reply Last reply
          0
          • A akash_omsairam

            First create a function like fun1() use this funtion [private\public\sub] fun1 ............ ....... ..... end sub

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            Did you even bother to read the original post?

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007

            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