vensim and vb6

Use this forum to post Vensim related questions.
Post Reply
mtirfan
Junior Member
Posts: 3
Joined: Wed Nov 19, 2003 6:09 am

vensim and vb6

Post by mtirfan »

Hello,

I am trying to use Vensim Full Dll to integrate vensim models with our Visual Basic 6 modeling application.

Within our vb6 application, I can open, add data (from our model to vensim), run and show results from models developed with Vensim. However, when I unload the vb6 form used for this purpose, I am not sure what's happening to the files and variables used by the vensim dll. I am asking this because, as the vb6 form is being reloaded, I am not able to delete the .vdf files I used before. I get a "permission denied" from vb. I cannot delete the files (at this stage) even in windows explorer. It says files are being used by some other application. If I skip the deletion of file deletion code, I get an error message further down where I am trying to load the (same) model again.

I tried Special>Clearruns, Menu>Exit etc., but they did not work.

Could you please help?

Thank you.

-Mohammod
Lee Jones

Post by Lee Jones »

Welcome to the forum!

I don't currently have time to test this but from what I understand of your problem, I would suggest trying the following Venapp command:

SPECIAL>STOPSIM|option

Stops a simulation. Use option of SAVE to save the results so far, NOSAVE to discard results and QUERY to ask the user. The options have no effect in gaming mode — the output is always saved. This command must appear first in the list of commands, and will be the only command executed during simulation. If this command is invoked and there is no simulation in progress, it has no effect, and the commands that follow it are executed.

Hope this helps.

Lee
mtirfan
Junior Member
Posts: 3
Joined: Wed Nov 19, 2003 6:09 am

Post by mtirfan »

SPECIAL>STOPSIM|option does not help. It stops a running simulation.

I need something which will free up (.vdf) files used by the vensim simulations I run by the dll.

Thanks anyway.

-Mohammod
Wilson
Administrator
Posts: 51
Joined: Thu Mar 06, 2003 5:05 am

Post by Wilson »

I've never used the Vensim DLL thru' VB6, but have you tried using the "vensim_get_info" command to find out the exact status of what is going on at different steps during you VB application. You can use this to tell you what model & vdf's are still loaded if any, amongst many other things.

Have a look in the Vensim help file for the exact syntax of the command required.

Does seem strange, if you have cleared all runs but they still appeared locked into the application.

Sorry I can't be of more help.
mtirfan
Junior Member
Posts: 3
Joined: Wed Nov 19, 2003 6:09 am

Post by mtirfan »

I think, I discovered one part of the problem.

The function vensim_get_data does not close the .vdf it opens for reading the data.

However, I still have one problem. As soon as I try Special>LoadModel upon reentering the vb6 form used for integration, I am thrown out of VB (IDE closes right away). I tried loading models from different folder (as suggested by vensim support) with different name. But same thing happens.

However, this does not happen with the example provided by vensim (it can be easily tested by adding a form to the example project) !

-Mohammod
Pierre
Junior Member
Posts: 7
Joined: Fri Nov 21, 2008 11:38 am

Post by Pierre »

Hi everybody !

I think I am encountering the same problem as in the previous message. I am using the function vensim_get_data() to read the .vdf file in an Excel/VBA workbook and according to the result, I may need to run my model with the same vdf name. However, this is impossible as the file .vdf seems to be still opened by the vensim-get_data().

Does anyone knows a trick to release the file in my VBA code?

Thanks.

Pierre
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

If you are using the current Vensim release it seems unlikely that the vdf file would be locked by vensim_get_data - what is the message you receive when you try to run?
Pierre
Junior Member
Posts: 7
Joined: Fri Nov 21, 2008 11:38 am

Post by Pierre »

Thanks Bob!

I am currently using Vensim 5.7. Once I have compared my results in Excel using the function vensim_get_data, if the result isn't good enough I relaunch a run using a command script but the run stops and Vensim asks me to choose another vdf file (with a openfile dialog box).

Pierre
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

Clearruns on the VBA side might help, but there may have been bugs in 5.7 on this (I kind of remember that, though it was a long time ago). If you execute the run from within VBA (Rather than opening Vensim DSS with a command script) you might get better results. Alternatively use the command script for everything and export the data for use in Excel.
Post Reply