Results 1 to 9 of 9

Thread: Indirect referencing (Resolved)

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Indirect referencing (Resolved)

    Hi,

    In some DOS languages we had a facility known as "Macro Substitution", whereby you could directly access the object named in a variable. e.g.

    strVar contained the string "File1"

    Assuming the Macro Substitution reference is "&" you could then access File1 by refering to it as

    &strVar

    I know that you can access controls in VB.NET in a similar way by using Collections, but can you do something similar with variables?
    Last edited by taxes; Jul 13th, 2004 at 07:36 PM.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  2. #2
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    Taxes,

    I'm not quite grasping your question, could you re-phrase it please.

    Whadayamean it doesn't work....
    It works fine on my machine!

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Originally posted by CyberHawke
    Taxes,

    I'm not quite grasping your question, could you re-phrase it please.

    Right,

    say i have a sub named TestThis() and a string variable named strTest.

    In VB.NET, can I put "TestThis" into strTest and then call the sub by using the contents of strTest?

    As I said, this used to be called Macro Substitution and was VERY useful.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  4. #4
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    You still didn't make yourself clear..
    \m/\m/

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Originally posted by PT Exorcist
    You still didn't make yourself clear..
    O.K. I'll try again.

    Dim strTest As String = "TestThis"

    Private Sub TestThis()
    MessageBox.Show("It Works")
    End Sub


    Can I call the sub TestThis by using strTest in some way?
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  6. #6
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622
    He is looking for something like the "CallByName" Method in VB6...

    not sure if it exists in .NET???
    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

  7. #7
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622
    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

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi ABX,

    Looks good. Yes, the CallBy Name function is still available. I'll look at that and your link tomorrow.

    Many thanks.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi ABX,

    Yes, the CallByName function works perfectly.

    e.g.
    VB Code:
    1. In an event or procedure.
    2.  
    3. Dim strTest As String="TestingThis"
    4. CallByName(Me, strTest, CallType.Method)
    5.  
    6.  
    7. Sub TestingThis()
    8.   MessageBox.Show("TestingThis Method Successfully Called")
    9. End Sub

    Many thanks, I've been looking for this for months.

    Now I can throw away my dBaseIII Plus
    Last edited by taxes; Jul 13th, 2004 at 07:59 PM.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

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