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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

handle events in VB6 2

Status
Not open for further replies.

theemperor

Programmer
May 22, 2001
28
AT
Hi all! Can anybody tell me how to react to events in VB6? My concrete proble is as follows: I try to convert a .ps-file into a .pdf-file using an object called ACRODISTXLib.PdfDistiller (Acrobat Distiller). It has got a function called FileToPDF which fires an event called OnJobDone if succeeded. Here is a code-snipplet:

Sub convertToPDF()
Dim oDist As ACRODISTXLib.PdfDistiller
Dim nRet as Integer, sFileIn as String, sFileOut as String

sFileIn = "C:\sampler.ps"
sFileOut = "C:\sampler.pdf"
Set oDist = New ACRODISTXLib.PdfDistiller

nRet = oDist.FileToPDF(sFileIn, sFileOut, "")
'nRet returns 1 upon success
End Sub

Thanx for the help, Robert
 
Move the declaration of the object into the globals section of a form or class module, and dim it with WithEvents:

Option Explicit
Public WithEvents oDist As ACRODISTXLib.PdfDistiller

 
Thanx for the clue, strongm. However, I still don't know how to use the OnJobDone-event in my code...I want to call another function if this event was fired, so how do I react to this event (something like: If OnJobDone then...?).
 
When you have moved the declaration and added with Withevents keyword like strongm has suggested, look in the drop down list of objects for oDist, then in the right hand list of events you will find OnJobDone. Select this event and the event will appear in the code window. In this code add your function call (or a msg box to test it).

Madlarry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top