|
-
Jul 13th, 2004, 12:40 PM
#1
Thread Starter
PowerPoster
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.
-
Jul 13th, 2004, 12:58 PM
#2
Hyperactive Member
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!

-
Jul 13th, 2004, 02:13 PM
#3
Thread Starter
PowerPoster
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.
-
Jul 13th, 2004, 03:30 PM
#4
yay gay
You still didn't make yourself clear..
\m/  \m/
-
Jul 13th, 2004, 04:27 PM
#5
Thread Starter
PowerPoster
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.
-
Jul 13th, 2004, 05:19 PM
#6
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
-
Jul 13th, 2004, 05:24 PM
#7
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
-
Jul 13th, 2004, 05:39 PM
#8
Thread Starter
PowerPoster
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.
-
Jul 13th, 2004, 07:35 PM
#9
Thread Starter
PowerPoster
Hi ABX,
Yes, the CallByName function works perfectly.
e.g.
VB Code:
In an event or procedure.
Dim strTest As String="TestingThis"
CallByName(Me, strTest, CallType.Method)
Sub TestingThis()
MessageBox.Show("TestingThis Method Successfully Called")
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|