Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is macro substitution available in .net
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01134885
Message ID:
01134946
Views:
20
>Hi All
>Is macro sustitution available in Visual Basic .NET Like VFP
>
>Ex. In vfp we can call a function by putting the function name in the variable.
>
>myfunction = "Function007"
>do &myfunction
>
>is such thing possible in .NET

As Cetin mentioned this is not possible but by using Reflection. At first, I thought this was a very difficult thing to handle. But, after having used it at several occasions for various needs, it is not so difficult after all. I was able to achieve all my goals so far, based from VFP upscaled code to .NET, where I had such need. As for this one, try this:
        Dim loClass As Type = Nothing
        Dim loObject As Object = Nothing

        Try
            loClass = Type.GetType("YourClass")
            loObject = Activator.CreateInstance(loClass)
        Catch loError As Exception
            oApp.ErrorSetup(loError)
            Return False
        End Try

        ' Then, from this point, you have a reference to loObject and you can call anything under it
        ' such as loObject.MyMethod()
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform