Vensim + VB.net

Use this forum to post Vensim related questions.
Post Reply
acta
Junior Member
Posts: 4
Joined: Wed Nov 17, 2010 5:07 pm

Vensim + VB.net

Post by acta »

Hi,

My name is Ana Cristina. I'm from Brazil.

I need some help with Vensim + VB.net

I'm trying to use the example from Vensim Help, but it doesn't seem to work correctly.

result = vensim_command("SIMULATE>RUNNAME|bobblah")
If result = 0 Then Exit Sub
num1 = txtVolumeInicial.Text
comstr = "SIMULATE>SETVAL|VOLUME INICIAL = " + Str(num1)
result = vensim_command(comstr)
If result = 0 Then Exit Sub
' now do the work
result = vensim_start_simulation(1, 0, 1)
If result = 0 Then Exit Sub
Do
result = vensim_get_val("Time", timeval)
If result = 1 Then
stime = timeval
Label2.Text = "Time = " + stime$
Label2.Refresh()
End If
result = vensim_continue_simulation(20)
If result <> 1 Then Exit Do
Loop
....

I get the correct result when I load the simulation and when I set value to the "volume inicial" variable.

I guess there's something wrong with my simulation when I try the vensim_start_simulation command, because it returns 8589031291658174465 instead of 1, although I get the message asking if I want to overwrite the dataset!
Then, as the "if" tests if result is not zero, the code execution continues and when I try the vensim_get_val command, I get an exception telling me that there was an attempt to read or write in protected memory.

Searching for similar situations in this forum I found something that gave me and idea. I tryed changing the function vensin_get_val subscription to use ByRef instead of ByVal. It made the exception disappear, but the function result is zero.

I don't know what else to do, since I'm using exact the same code as the example and it does not work (I know it's VB6 and there may be some changes, but... ).

Can anyone help me?

Thanks in advance,
Ana Cristina
Administrator
Super Administrator
Posts: 4845
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

What version of Vensim do you have installed and I'll try to re-create the error here.

Tony.
acta
Junior Member
Posts: 4
Joined: Wed Nov 17, 2010 5:07 pm

Post by acta »

Hi Tony,

I'm using version DSS 5.5d with Visual basic 2008 express.

thanks a lot!
Administrator
Super Administrator
Posts: 4845
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

I don't have easy access to a version that goes back as far as 5.5d.

Are you able to update at all to a later version (http://www.vensim.com/download.html)?
acta
Junior Member
Posts: 4
Joined: Wed Nov 17, 2010 5:07 pm

Post by acta »

I'll see what I can do tomorrow at work. I didn't realize it was so old! ;)


I'll be back as soon as I get any answer about that.

Thans Administrator.
acta
Junior Member
Posts: 4
Joined: Wed Nov 17, 2010 5:07 pm

Post by acta »

Tony,

We'll be purchasing a newer version in the few next days.

Can anything can be done before that? Any idea?

Thanks,
Ana Cristina
Post Reply