|
-
Aug 8th, 2002, 08:16 AM
#1
Thread Starter
Addicted Member
Executing a sub via parm pass
Hi,
Back in my AS400 days, you could call a program whose name
was strored in a variable "Call &PGMNAMESTOREDHERE" I wish to
do similar in my VB program. I want to execute a subroutine
whose name would be stored in a table. Is this possible?
Thanks
Tom
-
Aug 8th, 2002, 08:22 AM
#2
PowerPoster
Do you mean a subroutine that exists in your VB program or elsewhere (such as in a DLL) ?
If in VB prog, you can do it via "if then ... "(I know that's pretty obvious but though I'd mention it just in case) but I don't think there's any other way.
If in a DLL, there might be an API call you can use (but, again, I'm not aware of any)
-
Aug 8th, 2002, 08:26 AM
#3
Hyperactive Member
Actually his second idea works I am pretty sure. If you place them in a DLL, you can dynamically call functions. I did it for a math program I designed a while back, but I don't have the code on me. It involved using LoadLibrary to load the DLL and then I believe CallWndProc. Hope that helps.
Joe
-
Aug 8th, 2002, 08:32 AM
#4
Thread Starter
Addicted Member
Sub call
Phinds,
A call to a sub in the same VB program. Might sound odd, but
here is the reason: Base on the type of "container" that is
selected, the "containerization" of the product is different. That means a different form/subroutine for each container type. Container types are going to be added over time, so I will have to
hardcode the container type, requiring form changes,and
CASE,IF/ELSE selections modified. I would rather put the
container types to a table and call the appropriate subroutine whose name is stored in the record for the container type. This will reduce modifications in the future to just writing the sub and populating the container table. Just a pipe dream I guess
Tom
-
Aug 8th, 2002, 08:35 AM
#5
Well ...
This is what the vbapi says about CallWindowProc. I think it's basically for subclassing, and not for calling a procedure/function by name.
http://216.26.168.92/vbapi/ref/c/callwindowproc.html
To the best of my knowledge VB doesn't provide for a macro-style function calling by name.
.
-
Aug 8th, 2002, 08:35 AM
#6
Thread Starter
Addicted Member
PArm pass
Joe,
I can't go DLL route because of my lack of knowledge on how those are built/excuted. I should learn it, But I do not have the luxury of time to figure it out, but it does seem interesting. Maybe down the road. Thanks guys/gals anyway for responding
Tom
-
Aug 8th, 2002, 08:38 AM
#7
Hyperactive Member
My apologizes, GetProcAddress is what I meant. Then there was a manner to use that proc address to call the function dynamically. I know for a fact there is a manner to do it as I actually did it. I just do not have code here with me at work. Edit: Or did I cheat? I may have cheated. I am not sure to be honest. I may have cheated and passed the variable name to a predefined function that handled passing it to the next. Though, for some reason I am inclined to think that I called the function directly.
Joe
Last edited by Joey_k29; Aug 8th, 2002 at 08:41 AM.
-
Aug 8th, 2002, 09:46 AM
#8
Retired VBF Adm1nistrator
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Aug 13th, 2002, 07:00 AM
#9
PowerPoster
plenderj --- OUTSTANDING !!!
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
|