function pointers

I have defined a few functions in modules...my code needs to access a database(access) & get the related function name & call that particular function...Can it be storing a function pointer ?
Is this right ? or how to go about it ?Please help me asap
Thanks & Regards
Gomes
[285 byte] By [gomes] at [2007-11-15 18:34:35]
# 1 Re: function pointers
Hey,

Why don't you set up swich-case with function name as
Function CallThisFunction(strFunName as String) as long
[Code Here]
End Function

in this function you can compare name and call suitable function. No function pointers in VB :-)
newton131 at 2007-11-10 0:33:43 >
# 2 Re: function pointers
thanks Newton
I'll try that...
The problem is I have so many functions that writing a switch case will result in a not so optimistic code I guess
gomes at 2007-11-10 0:34:45 >
# 3 Re: function pointers
Depending on what things your functions are doing, you may have them as strings in Db, and run them as vbscript code
ie:

'add a reference to Microsoft Script control
option Explicit
private scrp as ScriptControl
private Sub Form_Load()
set scrp = new ScriptControl
scrp.Language = "Vbscript"
scrp.AddCode "if x <> 5 then msgbox""Hello!"" end if"
scrp.ExecuteStatement "if x <> 5 then msgbox""Hello!"" end if"
'you can add a string loaded from a text file!
scrp.AddCode "Sub DoThis" & vbCrLf & "msgbox ""Called a sub""" & vbCrLf & "end sub "
scrp.Run "DoThis"

set scrp = nothing
End Sub

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make dev-archive a great place.
Come back soon, you Gurus.

The Rater
Cimperiali at 2007-11-10 0:35:44 >
# 4 Re: function pointers
Thanx
My project has to generate JavaScript code...I'm not sure whether this will help
Gomes
gomes at 2007-11-10 0:36:51 >
# 5 Re: function pointers
Change language to javascript!
However, look also here:
'--
A better way to call fuunct and sub via strings:
using CallByName function!
More details here:
http://www.mvps.org/vbnet/
(or go to microsoft site)
and serach for:
Q186143 HOWTO: Use the CallByName Function to Run a Procedure
'--
Cesare Imperiali

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make dev-archive a great place.
Come back soon, you Gurus.

The Rater
Cimperiali at 2007-11-10 0:37:50 >