Solved

END function not supported in DLL format.

Posted on 2004-09-14
12
1,086 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…

943 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

11 Experts available now in Live!

Get 1:1 Help Now