I am trying to return the variable name as a string.
So, if the variable is var1, I want to return the string "var1".
Is there any way to do this? I heard that reflection can be in the right direction.
Edit:
I try to make the implementation of organized treeview simpler. I have a method that you give to two lines: rootName and subNodeText. The name rootName is the name of the variable. This method is called internally with a block for this variable. I want the user to be able to call the method (.getVariableAsString, subNodeText) instead of the method ("Variable", subNodeText). The reason that he wants to get it programmatically is because this code can simply be copied and pasted. I do not want to configure it every time a variable is called something abnormal.
Function aFunction() Dim variable as Object '<- This isn't always "variable". Dim someText as String = "Contents of the node" With variable '<- Isn't always "variable". Could be "var", "v", "nonsense", etc 'I want to call this Method(.GetName, someText) 'Not this Method("Variable",someText) End With End Function
source share