Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to end from ActiveX DLL?

Posted on 1999-01-20
8
Medium Priority
?
184 Views
Last Modified: 2010-05-03
hi,
I have a VB .exe which calls a function A from VB ActiveX DLL.
in function A, I have a message box. If the user selects  Yes, action will be done, else nothing is performed.
When I chose No, the form still appears. I tried to use the End keyword but it seems that this keyword can't be used in DLL.

Please advise how can i answer No and make the form disappears.

thanks,
andrea
0
Comment
Question by:andreat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 4

Expert Comment

by:gencross
ID: 1469753
Use unload formname and in the unload event say...Set objectDllName = Nothing

This should get rid of the reference to the Dll and close the form.


0
 

Author Comment

by:andreat
ID: 1469754
hi gencross,
just to further elaborate my qn,
actually, the message box is on a dummy form with no controls.
the codes are :
calling function
----------------
Private WithEvents mform As fdialog
with mform
   .show vbmodal
end with

fdialog
-------
Private Sub Form_Load()
Dim msg, style, title, Help, Ctxt, response, MyString
msg = "Do you really want to stop all operations?"
style = vbYesNo + vbQuestion + vbDefaultButton2
title = "Stop Operation"
response = MsgBox(msg, style, title)
If response = vbYes Then
    'perform some actions
End If
End Sub

so in this case, I can't use unload in the form_load right?
Please advise.
thanks
andrea
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1469755
1) You can't unload in form_load that does not work. You can unload in form_activate or form_show. Just put a variable to true and test for this variable in form_show for example.

2) End in a dll does not work. The dll function should return a value or something on which the client should test. The client can now unload in this case.

Please reject the answer of gencross if it is not sufficient.
0
Industry Leaders: 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:caraf_g
ID: 1469756
You can do something about your Show problem.

Create a new Sub in your form as follows:

Public Sub ExternalShow(objOwnerForm As Form, intMode As Integer)

Within this sub you can execute all the code that you have put into the Form_Load procedure

Dim msg, style, title, Help, Ctxt, response, MyString
msg = "Do you really want to stop all operations?"
style = vbYesNo + vbQuestion + vbDefaultButton2
title = "Stop Operation"
response = MsgBox(msg, style, title)
If response = vbYes Then
    'perform some actions
    Me.Show intMode, objOwnerForm
End If

And to call the form:
Private WithEvents mform As fdialog
with mform
   .ExternalShow vbmodal, Me
end with

(You can adapt the sub to
- not have an objOwnerForm parameter if you don't need it
- not have an intMode parameter if you're always going to show the form either modeless or modal.)
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1469757
You are free to unload the form within this sub
Unload Me

or from outside; it's up to you.
0
 

Author Comment

by:andreat
ID: 1469758
the answer is insufficient.

Mirkwood & caraf_g, I will try out your suggestions and then
revert to you for answering.

thanks,
Andrea
0
 

Author Comment

by:andreat
ID: 1469759
caraf_g : I've tried your suggestion but I get error 13 on
ExternalShow Me


Mirkwood : for my problem above, i can't return a value from form_load right? does it mean that I have to create another function X in fdialog and return a value from X? if that's the case, how do i call the function X from the calling project?

thanks,
andrea
0
 
LVL 10

Accepted Solution

by:
caraf_g earned 60 total points
ID: 1469760
You could "Translate" the intMode parameter, let's say you decide that 1 = modeless, and 2 = modal.

You can then change the code as follows

If response = vbYes Then
    'perform some actions
    If intMode = 1 then
        Me.Show vbModeless, objOwnerForm
    Else
        Me.Show vbModal, objOwnerForm
    End If
End If

Please note that you must call the procedure with 2 parameters, for example

   .ExternalShow 1, Me
or
   .ExternalShow 2, Me

Good luck
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

604 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