Results 1 to 9 of 9

Thread: Returning messages from Active X Dll

  1. #1

    Thread Starter
    Addicted Member wernerh's Avatar
    Join Date
    Sep 2000
    Posts
    170

    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!

  2. #2
    Junior Member
    Join Date
    May 2002
    Posts
    29
    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 ?

  3. #3
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    uk
    Posts
    327
    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...

  4. #4

    Thread Starter
    Addicted Member wernerh's Avatar
    Join Date
    Sep 2000
    Posts
    170

    Talking

    Thanks for the reply! I was looking at callbacks but it looks to complicated, I think the "events" will work great!

  5. #5

    Thread Starter
    Addicted Member wernerh's Avatar
    Join Date
    Sep 2000
    Posts
    170
    How Do I raise the event in my ASP page?
    I cant declare using "Withevents"!

  6. #6
    WALDO
    Guest

    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:
    1. Public Function MyMethod( _
    2.     ByVal MyParam As Integer, _
    3.     Optional ByRef ErrRetVal As Long, _
    4.     Optional ByRef ErrRetSrc As String, _
    5.     Optional ByRef ErrRetDesc As String)
    6.  
    7.     On Error Goto err_MyMethod
    8.  
    9.     'If It's Something You don't like...
    10.     If MyParam = 17 Then
    11.         'Raise an Error (arbitrary number)
    12.         Err.Raise vbObjectError + 8080, , "I don't like this number"
    13.     End If
    14.  
    15. exit_MyMethod:
    16.     'Do cleanup if necessary
    17.     Exit Function
    18. err_MyMethod:
    19.     ErrRetVal = Err.Number
    20.     ErrRetSrc = Err.Source
    21.     ErrRetDesc = Err.Description
    22.     Resume exit_MyMethod
    23. End Function

  7. #7
    WALDO
    Guest

    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 :)

  8. #8
    Addicted Member chander's Avatar
    Join Date
    Nov 2000
    Location
    New Delhi , India
    Posts
    225
    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 ...
    Chander
    Email:[email protected]

  9. #9
    WALDO
    Guest
    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
  •  



Click Here to Expand Forum to Full Width