Solved

END function not supported in DLL format.

Posted on 2004-09-14
12
1,081 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 10

Expert Comment

by:Clif
Comment Utility
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
Comment Utility
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
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 3

Accepted Solution

by:
aParser earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
OK... whew, I figured it out... having a mahor brain fart day... Thanks fo rall the help :-).
0
 

Author Comment

by:Wonderflub
Comment Utility
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
Comment Utility
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now