Building your own Visual Basic Simul8 program
Before you read this topic please take a look at the Overview of the Visual Basic Interface.
Run Visual Basic from Program Manager and create a New Project (File / New Project). (See also: EXE Programs)
Add the Simul8 declarations module to your project (File / Add File / and select S8DEC.BAS from the Simul8 directory on your disk).
Add a form to your project (or use the one that Visual Basic may have created when you said File / New Project) and change the form's LinkMode Property to 1-Source.
Add a text box or label to the form that will be used to communicate data to Simul8. (See also: Hiding Visual Basic from User)
Give the form some code for its LinkExecute procedure. The CmdStr parameter of LinkExecute contains text from Simul8 telling your LinkExecute procedure that part of your Simul8 simulation is requesting information from your Visual Basic program.
You specify this text in the LinkExecute Command box in the dialogs in Simul8 that allow you to say that Visual Basic is to be used (for example in External Distributions).
Your LinkExecute procedure should place in the text box or label (see (4) above) the appropriate information to be sent to Simul8 to tell it how to proceed (as a result of your Visual Basic program performing any calculations or decisions necessary).
In order to make the decision / perform the calculations your program can ask Simul8 about the current state of the simulation by calling any of the supplied SUBs or FUNCTIONs in S8DEC.BAS. See: The State of Your simulation
Run your Visual Basic Program (press F5)
Go back to your simulation (press ALT-TAB to find Simul8 or run Simul8 and load your simulation).
In the dialog where you want information from Visual Basic (e.g. an External Distribution):
Specify the name of your program,
The name of your form's LinkTopic (usually the same name as your form)
The name of the label that will contain the information requested by Simul8
Any additional information required to indicate to your Visual Basic program the part of your Simul8 simulation that is requesting the information.
Run your simulation. Simul8 and Visual Basic will automatically talk to each other at the appropriate times.