Results 1 to 5 of 5

Thread: Reflection - Get byref Variable name?

  1. #1

    Thread Starter
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    Reflection - Get byref Variable name?

    Say i have a some code in my Form_Load

    VB Code:
    1. 'Do something
    2. Dim intValue as Integer = 1
    3.  
    4. intValue *= 5
    5. intvalue += 1
    6.  
    7. DoSomething(intValue)


    VB Code:
    1. Public Sub DoSomething(byRef Value as INteger)
    2.    ' Can i find the orginal  variable name in here? "intValue"
    3. End Sub
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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()

  3. #3

    Thread Starter
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    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.
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    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?

  5. #5

    Thread Starter
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    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.
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width