Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can Perl call a VB program or vice versa?

Status
Not open for further replies.

Kathy1

Programmer
Dec 21, 2000
39
0
0
US
Hi All.

We have some Visual Basic subroutines that access a DB2 database (read/write) and a sequential text file(write). I'm creating some new applications in Perl, and they need use functions exactly like the ones we already have in VB. Is it possible for me to call VB functions from a Perl program? And while I'm asking, is it possible to call a Perl function from a VB program? Or are these languages incompatible?

Thanks! X-)

Kathy
 
That should be possible, yes. I found this example in the standard Perl documentation that describes how to access MS Word routines:
[tt]
use strict;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Word';

my $Word = Win32::OLE->new('Word.Application', 'Quit');
# $Word->{'Visible'} = 1; # if you want to see what's going on
$Word->Documents->Open("C:\\DOCUMENTS\\test.doc")
|| die("Unable to open document ", Win32::OLE->LastError());
$Word->ActiveDocument->PrintOut({
Background => 0,
Append => 0,
Range => wdPrintAllDocument,
Item => wdPrintDocumentContent,
Copies => 1,
PageType => wdPrintAllPages,
});

or simply

$Word->ActiveDocument->PrintOut;
[/tt]
example is at:
file://C:\Perl\html\faq\Windows\ActivePerl-Winfaq12.html
on my system

So - you can call OLE routines from Perl then, you just need to write your VB DLL's as an OLE server.
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Thank you Mike. We may attempt this. I'll have to see if the VB programmer can do this for us.

Kathy :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top