Reflection - Get byref Variable name?
Say i have a some code in my Form_Load
VB Code:
'Do something
Dim intValue as Integer = 1
intValue *= 5
intvalue += 1
DoSomething(intValue)
VB Code:
Public Sub DoSomething(byRef Value as INteger)
' Can i find the orginal variable name in here? "intValue"
End Sub
Re: Reflection - Get byref Variable name?
Not unless you can (somehow) decompile all the code in the assembly file and look for an instance of a line in there which is calling the subroutine DoSomething(), and then parse it.
But since this is being done in your own application, shouldn't you approach this in a more conventional manner? Pass some sort of a parameter depending upon what you want to do. Or just pass the name of the variable to DoSomething using String.Parse()
Re: Reflection - Get byref Variable name?
The reason why i ask is i constantly am writing the same debug code over and over again.
Debug.writeline("VariableName: " & VariableName)
Or
Debug.WriteLine("Namespace.ClassName.MethodName.VariableName" : & Variable Name)
what i wanted to do is write a function that did all the work for me.
I Guess i will have to settle for passing the Variable name as well.
Re: Reflection - Get byref Variable name?
Why do you need to write any code for that? You can get all that info and more from the IDE itself. Try using the Local, Immediate, or Watch windows and you can drill down to whatever you need. Also within the function the variable would be the name of the parameter, so what is the difference what it was called when passed in?
Re: Reflection - Get byref Variable name?
This is a more larger web application then i would like it to be and it makes it easier if i a have debug information for other classes while im debugging a different one.
When i make a mistake that could be anywhere in between the database logic and the webform it kind of helps to be able to set a debug contant(soon i will change this to always to it if a debugger is attached) and watch all the info flow.