Imports System.IO

Module Module1

Sub Main()

   ' Illustrates how to call the Lingo command-line tool RunLingo.exe
   ' to solve a small transportation model.

   Dim process As New Process()

   'Lingo's command-line tool
   process.StartInfo.FileName = "\lingo64_18\runlingo.exe"

   'The transportation model
   process.StartInfo.Arguments = "\lingo64_18\tran.ltf"

   'Send stdout to a log file
   Dim logFile As New StreamWriter("\lingo64_18\lingo.log")

   'Go ahead and start the process
   process.StartInfo.UseShellExecute = False
   process.StartInfo.CreateNoWindow = True
   process.StartInfo.RedirectStandardOutput = True
   process.Start()

   'Capture the log
   Dim streamReader As StreamReader = process.StandardOutput
   logFile.Write(streamReader.ReadToEnd())
   logFile.Close()

   'Wait for Lingo to finish
   process.WaitForExit()

End Sub

End Module

