dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: using ActiveX object by reference

  1. #1
    Join Date
    Jun 2001
    Posts
    58

    using ActiveX object by reference

    Hi guru!

    Could you please tell me how to use ActiveX control by using reference in VB!
    I have made my own MessageBox object and i want to use it like the way people use recordset object of ADO:

    Dim rst As ADODB.Recordset
    Set rst = New ADODB.Recordset


    and after that use rst

    How can i use my MessageBox object like this way?

    Thanks!

  2. #2
    Join Date
    Apr 2002
    Posts
    388
    Code:
    dim msgbox as YourMsgBox
    set msgbox = new YourMsgBox
    
    msgbox.ShowOK "Hallo, DU"
    This works if you created a class called YourMsgBox.
    With the set msgbox = new YourMsgBox command you create a new instance of this class.
    If you have a ShowOK method in this class you would call it as i show you above.

    hope i could help you, if not please exact your problem
    mfg Ungi

    Music, music and VB. VB is like music: You never know how it is interpreted.

  3. #3
    Join Date
    Jun 2001
    Posts
    58
    Hi Ungi!

    Thanks for your help!
    Of course i used the same code as your guide but i receive the message Invalid use of New keyword. Follow is my code, my messagebox with named: ASMessageBox

    Dim myMsg As ASMessageBox
    Set myMsg = New ASMessageBox


    I do the following things:
    1/. Referent to my control by using Project/References and browse to my OCX file
    2/. and use the code
    Dim myMsg As ASMessageBox
    Set myMsg = New ASMessageBox


    and i receive the error message as above.
    By adding my OCX as component, i can use my ActiveX with no problem.

    This is my detail problem, could you please tell me how to solve it!

    Thanks for you help!

    Chua

  4. #4
    Join Date
    Apr 2002
    Posts
    388
    if you are using an OCX-Control you usually have to "draw" it on a form give it a name and so you could reference it. (like the CommonDialogControl)
    mfg Ungi

    Music, music and VB. VB is like music: You never know how it is interpreted.

  5. #5
    Join Date
    Jun 2001
    Posts
    58
    Hi Ungi!

    I see some component can be used by using reference like this way such as Shocwave Flash activeX control(Flash.OCX)


    dim myF as ShockwaveFlash
    set myF = new ShockwaveFlash


    Could you please have a look!

  6. #6
    Join Date
    Apr 2002
    Posts
    388
    for the best mail me a version of your control to chu2909@web.de so i could have a look on it
    mfg Ungi

    Music, music and VB. VB is like music: You never know how it is interpreted.

  7. #7
    Join Date
    Apr 2002
    Posts
    388

    it works!!

    i just draw such a ASMessageBox on my form and then i said at form_load

    Code:
    ASMessageBox1.MessageBox "Hallo"
    And it worked perfect.

    By drawing it on the form the ASMessageBox gets instanced by the variable ASMessageBox1. and with this variable you could do what you ever want.
    mfg Ungi

    Music, music and VB. VB is like music: You never know how it is interpreted.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)