Skip to content Skip to sidebar Skip to footer

Link Visual Basic With Python

i've been searching about how to link visual basic with python file i've tried so hard through using shell in Visual Basic but nothing happend i have python file called Go.py an

Solution 1:

First, you can use Shell, although it's unfortunately probably more complicated than you imagined.

Your current problem is a simple one - Shell can't run a python file directly, so you need to have Shell call cmd /c python.exe Go.py, and you may need to provide a full path to python.exe as well.

However, you also want to capture the result, and Shell only returns the process ID, not any kind of process output. You can check out some examples of external process invocation, although they don't explicitly cover how to capture output. If Go.py outputs to the terminal, you can probably capture the output into a file using standard Windows output redirection, and then open the file in VisualBasic and read the values.

You can also use System.Diagnostics.Process() instead of jumping through all the hoops of trying to get more functionality out of Shell. (Specifically, review the ProcessStartInfo class properties related to output redirection which give you much more control than anything using Shell will).

Post a Comment for "Link Visual Basic With Python"