Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am trying to learn how to make an ActiveX control. I followed a tutorial but all it does is make a messagebox come up with its titlebar having the name of the control. What is it supposed to teach me? I am pasting the code unless its wrong.

    I compiled the control but it does not do anymore.

    I am trying to find out the basics of building an ActiveX control, in particular to data being passed into the control from a form and data being sent back to the form. I have looked everywhere for simple instructions but so far without luck. Thanks

    Code:
    Dim TextVariable As String
    Event Click()
    Event KeyPress(Keyascii As Integer)
    
    Private Sub Command1_Click()
    MsgBox (TextVariable)
    RaiseEvent Click
    End Sub
    
    Private Sub Command1_KeyPress(Keyascii As Integer)
    RaiseEvent KeyPress(KeyAscii)
    End Sub
    
    Private Sub MyControl_ReadProperties(PropertyBag)
    TextVariable = PropBag.ReadProperty("Text", "There is no message")
    End Sub
    
    Private Sub MyControl_Resize()
    Command1.Width = MyControl.Width
    Command1.Height = MyControl.Height
    End Sub
    
    Public Property Get Text() As String
    Text = TextVariable
    End Property
    
    Private Sub MyControl_WriteProperties(PropBag As PropertyBag)
    Call PropBag.WriteProperty("Text", TextVariable, "There is no message")
    End Sub
    
    Public Property Let Text(ByVal New_Text As String)
    TextVariable = New_Text
    PropertyChanged  "Text"
    End Property

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    With the release of .Net, Microsoft has deemphasized ActiveX controls (COM objects) and this makes the documentation more difficult to find. However, I suspect that there were a lot of articles from five to ten years ago that might still be available on the web. For example, this one is listed under "Visual Basic 6" on MSDN: Creating an ActiveX Control. Is that the one you already tried? Google turned up a couple that look interesting, okay, complicated. This one seems pretty thorough, although I can't say I understand much of it: HOWTO Lesson 3: Creating .OCX's.

    Hopefully someone else can help more. I think I'm going to move this thread to the "Windows Programming" board, since VBA is more about in-Office development.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Many thanks. Yes I had come accross those two. I have tried lots of other examples but none seem to get passed the RaiseEvent command. Such a simple amount of code but just does not fire. I have Visual Basic 2008 Express on my pc, but template for ActiveX is not there. When I select find on web it does nothing, don't know if thats a limitation (MS Brick Wall) or something else. However thanks for comming in. I wondered where my post went to. Regards

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Quote Originally Posted by ZOR View Post
    I have Visual Basic 2008 Express on my pc, but template for ActiveX is not there. When I select find on web it does nothing, don't know if thats a limitation (MS Brick Wall) or something else.
    It's possible that the Express editions do not let you create ActiveX controls; I think that was one of the limitations of the original (2005?) Express edition for Windows development, and I don't know whether they changed that in the 2008 editions.

    I suspect there is a considerable difference between the way you created ActiveX controls in VB6 -- which pre-dates .Net -- and later editions. I may have provided incorrect advice assuming you had VB6. I think you will need to look for articles about how to create ActiveX controls in the .Net environment. (Sorry I can't help more, but all the compiled code I've created came out of the tools supplied with Office 2000/XP Developer Editions.)

  5. #5
    New Lounger
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    You can not create ActiveX controls in Express Editions. Look at http://social.msdn.microsoft.com/For...e-b3f7c170da99, maybe that will help.

  6. #6
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Many thanks Dejan. Typical, you can walk so far and then the brick wall. Thought it was the case so I have flipped back to VB6. It's all about money and too many directions to go in. Thanks, have a good weekend and all the best seasonal greetings.

Posting Permissions

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