Calls to and from Visual Basic

LANSA

Calls to and from Visual Basic
Example 236 - Rating: specific
The Things that Make Up this ExampleTo Execute this Example

This example shows how a Visual Basic program can start a Visual LANSA program and pass parameters to it, wait for the Visual LANSA program to end, and receive back data from the called Visual LANSA program.

It also shows how a Visual LANSA program can call a Visual Basic program and pass parameters to it, wait for the Visual Basic program to end, and receive back data from the called Visual Basic program.



Notes and Suggestions

VB calls VL

The user of this example starts by executing Visual LANSA form S_236FA. This is a convenient way of supplying the fully qualified X_RUN string needed by the VB program SET_236B. (In a real VB application, the fully qualified X_RUN string would probably be largely hard coded into the VB code).

The user starts the VB program by double clicking on SET_236B.exe. It receives user input (including the X_RUN string), writes the data to be passed to a CSV (Comma Separated Values) file, and then starts the Visual LANSA form S_236FB using the X_RUN string. The VB program uses the CreateProcess method of executing the X_RUN string, instead of the Shell method, because CreateProcess allows the VB program to wait for the Visual LANSA program to finish.

The Visual LANSA program reads the CSV file and presents the passed data to the user (along with some other employee details retrieved from the database) . It then receives the users input and when the user presses the update button, it updates the employee’s salary in the database, writes the data to be passed back to another CSV file, and then closes and returns control to the VB program. The VB program reads the CSV file produced and presents the returned data to the user.

VL calls VB

The user of this example starts by executing Visual LANSA form S_236FX. This receives the user input and then when the user presses “call vb program”, it writes the data to be passed to a CSV file, and then starts the VB program SET_236X.exe using the SYSTEM_COMMAND built in function.

(In this example the directory of SET_236X.exe is known to be the partition execute directory)

(In this example the partition-execute-directory is also used for the CSV files. The working directory parameter of the SYSTEM_COMMAND bif is used tell the VB program to look in the partition-execute-directory for any CSV files.)

The VB program is started and reads the CSV file and presents the passed data to the user. The user edits the data and presses “return to vl”. The VB program writes the data to be passed back to another CSV file and ends, returning control to the Visual LANSA program.

The Visual LANSA program reads the CSV file and presents the returned data to the user.

This Example Is Useful Because:
  • At times it may be necessary to integrate VL and VB applications
Keywords
Example 236Visual Basic
VBSYSTEM_COMMAND
X_RUN