Solved

END function not supported in DLL format.

Posted on 2004-09-14
12
1,111 Views
Last Modified: 2006-11-17
I have a program I mistakenly created as a standard ExE and when I recreated it in an ActiveX DLL format and imported my classes, it tells me that the END function is not supported in a DLL, how do I get the program to terminate when a certain error is encountered, IE run flag already set?
0
Comment
Question by:Wonderflub
  • 7
  • 2
  • 2
  • +1
12 Comments
 
LVL 4

Expert Comment

by:P1
ID: 12058242
You shoulder never end a ActiveX/COM object internally, always report/return an error back to the client.  

Regards,  P1
0
 

Author Comment

by:Wonderflub
ID: 12058291
I need the program to terminate once the active flag is located, it cannot continue to run, so how would I accomplish this?
0
 

Author Comment

by:Wonderflub
ID: 12058430
actually, the error is being thrown when the SQL database for logging cant be opened, I figured out how to get around the active flag, the whole proggy is one big IF, then statement... but if the database wotn open, it need to terminate... how prey tell, how.....
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:Clif
ID: 12058492
Return an error then end the calling program.  That will end the dll.

That's about the only way you can do it.
0
 

Author Comment

by:Wonderflub
ID: 12058538
how do I end the calling program from the DLL when I am using a VB script to call the program?

I may be being really lazy here and not wanting to look it up, but help a sister out :-).
0
 
LVL 10

Expert Comment

by:Clif
ID: 12058573
You don't end the calling program from the dll, you end the calling program from the calling program.  In the case of script, exit the procedure where you created the object.

Which brings up a point. If you created the object, destroy the object (set it to nothing).
0
 
LVL 3

Accepted Solution

by:
aParser earned 500 total points
ID: 12058580
Sub Main()
  Dim oMyObject As MyClass

  Set oMyObject = New MyClass
  On Error GoTo Err_Sub
  If OneBigIfStatement Then
  ...
  End If
  Exit Sub
Err_Sub:
  Set oMyObject = Nothing
End Sub

[MyClass.cls]
...
Public Sub MyMethod()
  Const VBERRROR_USER_INTERRUPT As Long = 18 ' for illustration only
  If Not ConnectToDatabase() Then
    Err.Raise VBERRROR_USER_INTERRUPT
  End If
  ...
End Sub
...
0
 
LVL 3

Expert Comment

by:aParser
ID: 12058653
Scripting ... bleh ...

Sub Main()
  Dim oMyObject

  On Error Resume Next
  Set oMyObject = CreateObject("MyProject.MyClass")
  If OneBigIfStatement Then
    ...
    Call oMyObject.MyMethod
    If Err.Number <> 0 Then
      Set oMyObject = Nothing
      Exit Sub
    End If
  ...
  End If
End Sub

0
 

Author Comment

by:Wonderflub
ID: 12058672
Ok, ok, I know you are going to hate me for being a little slow and a real pain in your ass.... BUT how can I do all this from inside a VB script, I don't work with VB script, I just use it for the job sceduler to call programs and it is one line of code.....

DLLName.function name

can you use subs in vbscript like that.....
0
 

Author Comment

by:Wonderflub
ID: 12058726
OK... whew, I figured it out... having a mahor brain fart day... Thanks fo rall the help :-).
0
 

Author Comment

by:Wonderflub
ID: 12058747
Oh my aParser, your post got in there while I was posting mine and never saw it..... my appologies, go to thread to follow to make up for my totally brainless day
0
 

Author Comment

by:Wonderflub
ID: 12058759
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question