-
Dec 16th, 2010, 10:06 AM
#1
Thread Starter
Lively Member
Using Python with Vb6
well i've searched for two days on how to fix this problem and found nothing. what i'm trying to do is call python functions and stuff from within vb6. Here's the steps I took
1) I have vb6 and sp6 installed
2) I install activepython 2.7 because it includes win COM stuff
3)I create the folder C:\PythonVB
4)I created the python script called 'PythonVB3.py' with the following code
Code:
class PythonVB3:
#Public Methods available to VB
_public_methods_ = ['SayHello']
#Class Name Created in VB.
#Example Set objPython = CreateObject("PythonVB3.Demo")
_reg_progid_ = "PythonVB3.Demo"
#Never Copy this GUID! Use pythoncom module to create a new one
#Example: import pythoncom
# print pythoncom.CreateGuid()
_reg_clsid_ = "{EE2946AE-79DD-49D1-992D-F4FF6431A2F0}"
def SayHello(self):
return "Hello from Python!!"
if __name__ =='__main__':
print "Registering COM Server..."
import win32com.server.register
win32com.server.register.UseCommandLine(PythonVB3)
5) I double clicked the script above which registered itself
This tool 'RegDLLView' from nirsoft shows it registered correctly
6)I created a new standard exe project in vb6 with the following code
Code:
Private Sub Form_Load()
Dim objPythonVB As Object
Dim retval As Long
Set objPythonVB = CreateObject("PythonVB3.Demo")
retval = objPythonVB.SayHello()
MsgBox retval
End Sub
7)when I compiled and try to execute(in C:\PythonVB) I get error
I tried manually adding a reference to pythoncom27.dll too and it wouldn't let me :\ any help or advice would be much appreciated. I also uninstalled/reinstalled everything and only have 1 version of python installed.
-
Dec 16th, 2010, 05:51 PM
#2
Thread Starter
Lively Member
Re: Using Python with Vb6
ok I got it to work, i'll leave it unanswered for a day to let people guess if they want. i'll give you a hint though, there's nothing wrong with the code short of retval being declared a long when it should be a string. That's not the main issue though.
-
Oct 5th, 2017, 09:44 AM
#3
New Member
Re: Using Python with Vb6
Sir,
how did you manage to work through this? I would be highly interested in learning the solution as I'm facing similar issues.
Bart
-
Jul 14th, 2021, 03:14 AM
#4
Addicted Member
Re: Using Python with Vb6
Originally Posted by Vbstr
ok I got it to work, i'll leave it unanswered...
Vbstr's last theorem
-
Jan 3rd, 2025, 01:47 PM
#5
Junior Member
Re: Using Python with Vb6
Could someone please help with this topic since the thread's author disappeared?
-
Jan 9th, 2025, 12:14 PM
#6
Re: Using Python with Vb6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|