First, I suggest to read some help about the CallByName function,
Since it's more advanced than simple functions
Try using MSDN documention if you have it installed, or also at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr...
vafctcallbynamefunction.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn...
vbconCallingPropertyOrMethodUsingStringName.asp
Quote:
> This is all the same as:
> Call Me.lblMenuItem.Caption
> is it not?
In this case it's the same, although when using 'Call' the return value is
ignored.
I didn't quite understand, how the TreeView is related to the dynamic menus?
In anycase, you can't perform the executaion of 'Call
Me.lblMenuItem.Caption'
dynamically at run time, just because a .Tag property of some object,
specified it as a text.
This is where CallByName can help
(Unless, you perform Case block for all possible choices, which is less
convenient)
You specified that this is what you need:
Quote:
> Call tvwMenu.SelectedItem.Tag , where tvwMenu.SelectedItem.Tag =
"printbilling"
In order to execute it using CallByName, then a procedure called
printbilling must exists!!!
Also in case you write the printbilling procedure, then it need to be
Public.
One problem though, in case the printbilling procedure excepts argument,
and/or has a return value,
then you need to know it in advance, so you could pass those arguments.
In case the procedures you plan to execute according to the text in the .Tag
property,
Have different arguments list, then a general CallByName call is not good
enough.
If all of the procedure you plan to execute have the same arguments type,
and return value type.
Then you can use CallByName easily.
If the above explanation doesn't solve your problem,
Please send me your sources (ONLY IF IT'S NOT CLASSIFIED),
and detailed explanation of what you try to achieve,
since there might be other solutions to your problems, like using interfaces
Quote:
> I've tried this:
> Call CallByName(me.lblMenuItem, "Caption, vbGet)
> and
> CallByName me.lblMenuItem, "Caption", vbGet
> and
> strCodeToRun = CallByName me.lblMenuItem, "Caption", vbGet
> call strCodeToRun
> This is all the same as:
> Call Me.lblMenuItem.Caption
> is it not?
> None of the above work.
> Can you help more?
> > Try using the CallByName command
> > > My menu items are held in a database, along with the associated
program
> to
> > > run when that menu item is chosen. I load the menu at runtime, and
when
> > the
> > > user clicks on the menu item in the treeview, I want to call the sub
or
> > > function held in the "tag" property of the selected item.
> > > something like this:
> > > Call tvwMenu.SelectedItem.Tag , where tvwMenu.SelectedItem.Tag =
> > > "printbilling"
> > > Any suggestions?
> > > Thanks
> > > Michael