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
Vensim + VB.net
-
- Super Administrator
- Posts: 4845
- Joined: Wed Mar 05, 2003 3:10 am
-
- Super Administrator
- Posts: 4845
- Joined: Wed Mar 05, 2003 3:10 am
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)?
Are you able to update at all to a later version (http://www.vensim.com/download.html)?