0

I want Write a function that can return the variable/object name as string like this :

    Dim SecondValue as Integer
    NameOf(SecondValue) 'Return "SecoundValue"

Can someone help on how to write the 'NameOf'?

  • 2
    If `Return NameOf(SecondValue)` does not work, then which version of Visual Studio are you using? Perhaps [VB.NET function get property name as string](https://stackoverflow.com/a/28036760/1115360) would help. – Andrew Morton Aug 02 '19 at 10:35
  • NameOf(SecondValue) does work. but i want send My Variable to my procedure and get this name on that proc. – Mohammadsaeed Mahdavi Aug 02 '19 at 15:18
  • I think you would have to call your procedure with `MyProcedure(myVariable, NameOf(myVariable))`, and adjust your procedure's parameters, because the variable names do not exist at run-time. – Andrew Morton Aug 02 '19 at 16:08

0 Answers0