• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 613
  • Last Modified:

Dynamically load & execute VB function

Hello,

I'm using MS Access for fast multi-thread web pages download  from the internet and save parsed results into database or files

I would like to create sort of profiles for each job
I need a way to setup number of functions like Start_Download() and Finalize_Download() for each profile

and I want to display profiles in drop-down menu, so once user select some profile and click "GO" button I want my program to call functions (Start_Download() and Finalize_Download()) of selected profile
and I want this functions to have access to few global variables.

I have tried to use separate modules for each profile

I can do something like "call Module1.Start_Download(parameters)" but for some reason I can't use something like
 call Me.Application.Modules("Module1").Start_Download(parameters) (it said function is not found)
and also Eval("Module1.Start_Download(parameters)") is not working.

I don't mind to  use Classes instead of functions as long as I can select class by name (programmatically) - if someone can give me an example of how to use nested classes in different modules

any idea on how to accomplish this?

I could use One module and modify this module with different programs for each profile stored in databases (or modules) but i don't want to do it because it will be hard to control & save future program modifications in this approach.


Any help is appriciated
0
DRY_GIN
Asked:
DRY_GIN
  • 3
  • 3
1 Solution
 
Alan WarrenCommented:
Hi DRY_GIN,

Is this an Access application or ASP?
Are you using the Access database just to store data or...?

Alan
0
 
DRY_GINAuthor Commented:
it's microsoft Access Application

I figure out some way to implement this, the only problem is that it seems to me it that Module1.function and Module2.fuction can not co-exist if they have the same name, so for now instead of it i'm using
module1.fucntion_1 , module2.fucntion_2 ...

and I'm calling functions as

Application.Run "function_" & i ,  some parameters

it is working quite well, still it's not a perfect solution because i need to rename same functions for each new profile.

0
 
joekendallCommented:
Are these functions in Access?

You can't have 2 functions named the same in Access. It doesn't accept Overloading so it doesn't know which function to call.

Why do you need to 2 different functions? Are they identical or are the different in some way? Can you post your code and maybe some changes could be made to make it work?

Joe
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
DRY_GINAuthor Commented:
I have a package (big set of functions, objects and tables) to do some job (web page download) with timers data processing ect.
now I want to use it for the different purposes.

for example I want to download 100000 pages from web site one -and parse whose pages into database - this require some additional coding.
tomorrow let's say I want to download 20000 images from web site 2 - so it will be another set of small additional functions to process with this images

I want to store all this "additions"  somehow inside my program for later usage.

Each of this jobs has it's own set of 6 small functions

OnStart
OnStop
PrepareNewDownload
FinishDownload
OnError
OnTimeOut
this 6 functions are not identical from job to job

in my main package I want to Call functions related to selected job (selected profile) during the process


So question was how to store pieces of Visual Basic code for different jobs inside one MS Access application (MDB file)

to have ability to use it later.

And later on if I select let's say job N10  I need some how to Use this 6 functions of Job 10 WITHOUT nasty Select cases like

Select JobID
 case 1:
   call onStart1
case 2
 call onStart2
....  <--- ugly


I don't know how else to explain

0
 
joekendallCommented:
I believe you have 3 choices. You already know about 2 of them.

1 - Use the Select Case statements
2 - Make different functions for each JobID
3 - You can insert VB code into a module in Access. You can look up information in the help file about the Module Object.

Joe
0
 
DRY_GINAuthor Commented:
I believe i already know about 3 of them.

" You can insert VB code into a module in Access" - did you read my question:
-"I could use One module and modify this module with different programs for each profile stored in databases (or modules) but i don't want to do it because it will be hard to control & save future program modifications in this approach
0
 
joekendallCommented:
If I missed that part, I am sorry.

Since you already know 3 different ways to do it, I guess I can't be of any help. Maybe Alan has some insights.

Joe
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now