Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 27th, 2003, 08:28 AM
Registered User
 
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aliawan
Default execute function whoses name is stored in a variab

how to execute a function whoses name is stored in a variable like function is test and variable is xx
xx = "test"
how to execute test function stored in xx


Muhammad Ali Awan
 
Old January 29th, 2005, 07:14 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hi aliawan,
xx = "test
 You can use execute(xx)

Hope this will help you

Cheers :)

vinod
 
Old January 31st, 2005, 11:50 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Vinod, where do you find an Execute in VB? I have never seen this.
When I look in help, there is no such reference.
When I use auto-lookup, there is no such entry.
When I look in object browser, there is no 'Execute.'

Muhammad, why do you want to do this? (I ask because it is an unusual task, and there might be a better way to do what you are attempting.)
 
Old February 1st, 2005, 02:42 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii BrianWren
Sorry !!!,
While posting the answer i thought that I am in VBScript Forum.:(
 
Old February 1st, 2005, 08:54 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

put the "test" method in a class and call it by using CallByName

i.e. to call "test" of the class CTest:

dim c as new CTest
CallByName c, "test", vbMethod

Marco
 
Old February 4th, 2005, 05:01 AM
Authorized User
 
Join Date: Jan 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

marcostraf is right u can call the the function by name,

But for that u do not have to create the class, as form's in which u r working r classes, so u can use form object to execute the clas.

something like this.

You 'll need the callByName-function
Example:

Private Sub Command1_Click()
    CallSubroutine "SubA"
End Sub

Private Sub Command2_Click()
    CallSubroutine "SubB"
End Sub

Private Sub CallSubroutine(ByVal sub_name As String)
    CallByName Me, sub_name, VbMethod
End Sub

Public Sub SubA()
    MsgBox "This is SubA"
End Sub

Public Sub SubB()
    MsgBox "This is SubB"
End Sub


Hope this will work and more near to your requirement, but both the solutions are same, other then u do not have to create extra class for execution the function by name.

**vinod --> as execute is a very helpfull function in vbscript, which i would not have any idea.

Amit Jain
Sr. Software Engineer





Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute Stored Procdure from Javascript(JS) file AbrarNazeer Javascript How-To 1 March 18th, 2008 06:39 AM
Updating Session Variab from Master Page gurbaksh ASP.NET 2.0 Professional 0 February 19th, 2008 05:50 PM
Execute Stored Procedure from VBA Romashka Access VBA 1 February 22nd, 2007 12:52 PM
public function execute = HELP! Return value ? davidkwang VS.NET 2002/2003 0 April 28th, 2004 12:18 PM
Analytical function and stored procedure akmhasan Oracle 2 November 14th, 2003 01:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.