VisualBots Event procedures give you the ability to design your own simulations and to facilitate object-user interaction.
Simulation Flow - the OnSimBegin, OnSimStep, and OnSimEnd
Events
When you click on the New Project button on the VisualBots Simulator, three event procedures are automatically created - the OnSimBegin, OnSimStep, and OnSimEnd event procedures. The OnSimBegin event procedure is executed once at the beginning of each simulation. The OnSimStep event procedure is executed at each simulation time step. And the OnSimEnd executes once during the termination of a simulation. You enter code into each of these procedures, depending on the desired simulation task. The flow diagram below illustrates the the event sequence that is executed during a simulation:

Actions that you might code in the OnSimBegin Event:
Actions that you might code in the OnSimStep Event:
Actions that you might code in the OnSimEnd Event:
BotOnClick and CellOnClick Events
The BotOnClick and CellOnClick event procedures return the nearest Bot or Cell object to the position of a mouse click on the screen. The procedures are useful for facilitating direct interaction between the user and the simulation objects. For example, one could write a CellOnClick event procedure to change the appearance of Cell objects when they are clicked on by the user.
Note: You must set the MouseEvents property to true before these events can trigger.
OnMouseMove, OnMouseDown, OnMouseUp
Events
The OnMouseMove, OnMouseDown, and OnMouseUp events return the location of the mouse on the VisualBots graphic window when the mouse is moved or clicked. The procedures are useful for facilitating interaction between the user and the simulation objects, such as programming a Bot to either follow or avoid the screen location of the mouse.
Note: You must set the MouseEvents property to true before these events can trigger.
The following example illustrates the use of the OnMouseMove event to facilitate user drawing.

How to Create an Event Procedure
The easiest way to write one of these event procedures from scratch is to select one from the event procedure drop-down list box in the Visual Basic Editor (see picture below). Make sure that the appropriate object is selected in the object list box.
