Solved

END function not supported in DLL format.

Posted on 2004-09-14
12
1,103 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

829 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