|
-
May 2nd, 2002, 02:19 AM
#1
Thread Starter
Addicted Member
Returning messages from Active X Dll
Hi, Is there a way to return messages from my Active X DLL to my ASP application. I know msgbox dont work, I am looking for something similar!
-
May 2nd, 2002, 04:51 AM
#2
Junior Member
Can you be more specific as to what you want to do ?
Where you want to store the returned messages ?
Session, Application or page level ?
-
May 2nd, 2002, 07:57 AM
#3
Hyperactive Member
You can get classes to raise events, and you can pass parameters to the events....
Declare the event at the top of the class like this:
Code:
Public Event Boo(ByVal Argh As String)
Then, anywhere in the class code, you can raise the event by using this syntax
Code:
RaiseEvent Boo ("Woooooo")
Next when you are using your ActiveX DLL, you must declare the object to include the events, like this:
Code:
Dim WithEvents ClassObject As MyAxDLL.clsObject
Then you simply declare the event sub as you do all other event subs -
Code:
Private Sub ClassObject_Boo(ByVal Argh As String)
MsgBox Argh
End Sub
Hope that helps...
-
May 3rd, 2002, 01:12 AM
#4
Thread Starter
Addicted Member
Thanks for the reply! I was looking at callbacks but it looks to complicated, I think the "events" will work great!
-
May 6th, 2002, 01:52 AM
#5
Thread Starter
Addicted Member
How Do I raise the event in my ASP page?
I cant declare using "Withevents"!
-
May 6th, 2002, 09:26 AM
#6
ChiefRB, that won't work with ASP
You could always raise custom errors, though. At the very least, return a status from your methods that you could use.
VB Code:
Public Function MyMethod( _
ByVal MyParam As Integer, _
Optional ByRef ErrRetVal As Long, _
Optional ByRef ErrRetSrc As String, _
Optional ByRef ErrRetDesc As String)
On Error Goto err_MyMethod
'If It's Something You don't like...
If MyParam = 17 Then
'Raise an Error (arbitrary number)
Err.Raise vbObjectError + 8080, , "I don't like this number"
End If
exit_MyMethod:
'Do cleanup if necessary
Exit Function
err_MyMethod:
ErrRetVal = Err.Number
ErrRetSrc = Err.Source
ErrRetDesc = Err.Description
Resume exit_MyMethod
End Function
-
May 6th, 2002, 09:31 AM
#7
Then test for the returned value
Code:
Dim objX, vntX, vntNum, vntSrc, vntDesc
Set objX = Server.CreateObject("MyDLL.clsMyClass")
vntX = 17
Call objX.MyMethod(vntX, vntNum, vntSrc, vntDesc)
If vntNum <> 0 Then 'Returned an error
If vntNum = vbObjectError + 8080 Then 'Our Custom Error
Response.Write "We Don't Like this parameter!!"
Response.End
Else
Response.Write "An Error Has occurred<br>" & vbCrLf
Response.Write "Error Number: " & vntNum & "<br>" & vbCrLf
Response.Write "Error Souce: " & vntSrc & "<br>" & vbCrLf
Response.Write "Error Description: " & vntDesc & "<br>" & vbCrLf
Response.End
End If
End If
'Continue as if success :)
-
Jul 1st, 2002, 03:00 AM
#8
Addicted Member
WALDO .. i couldnt get clear abt ur last example .. till Raising ERR i got but how to handle these err in ASP ..
well i have too similar kind of problem .. I am simply raising an event from DLL and i m using Object Tag of DLL in my ASP page ..
my properties / methods are working fine but i m not able catch DLL 's event as i cant use withevents ... can you please tell me more specificly abt ur example of Raise Err....
I would really appretiate ...
-
Jul 1st, 2002, 08:31 AM
#9
That's right, you can't catch events from ASP.
In my example, the method in the DLL catches errors and handles them by pushing them out to the three variant parameters (vntNum, vntSrc, vntDesc). These 3 params are representative of any error that occured in the DLL.
In ASP, you test for the value of vntNum returned from the DLL method. If it is not 0, then you have raised an error from your DLL and vntSrc and vntDesc should have values as well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|