I have a python module 'Cal.py' as below :
def Plus(a, b):
a1 = int(a)
b1 = int(b)
result = a1 + b1
return result
def Minus(a, b):
a1 = int(a)
b1 = int(b)
result = a1 - b1
return result
In Windows 10, I can call the functions with the arguments interactively from 'cmd.exe' :
D:\vb_python_SO>python
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import Cal
>>> Cal.Plus(2,3)
5
>>> Cal.Minus(5,3)
2
>>>
I would like to do exactly the same thing from Visual Basic 6. That is, function calling text from VB6 needs to be written after '>>>' and 'Return' key should be followed. But I could not find any nice solution yet.
I have tried the followings :
- VB6 'Shell ("cmd /k python.exe")' can do the upper part but cannot proceed after '>>>'.
- Writing a *.bat (or *.py) which also includes python function calling scripts. Executing it by Shell command can go further but functions cannot be called interactively, in which the arguments cannot be updated one after another from VB6 textbox.
Additional information)
My goal is to make a VB6 GUI program for calling Python functions. I need to control an instrument which measures certain characteristics of a sensor.
More specifically,
MyTester.py
def Init(_sensor_name='')
#Sensor Initialization Process
def GetExposure()
#Read Present Exposure Time from Sensor Register
def SetExposure(Exposure_Time)
#Write Exposure Time to Sensor Register
def FindExposure(...)
def MoveAbsolute(Rotation_Degee_A)
#Rotate Table to Absolute Angle
def MoveRelative(Rotation_Degee_R)
#Rotate Table by Relative Angle
def Roundtrip(...)
...
For now, function calls are performed at Python Shell interactively. It will become easier if I make a VB6 GUI program. Note that Init() function should be called at first and the other function calls follow.