VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Create an ocx (create a control) from VB to put in your own applications. This is an example on how

by Jessy Butzke (11 Submissions)
Category: OLE/COM/DCOM/Active-X
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 22nd January 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Create an ocx (create a control) from VB to put in your own applications. This is an example on how to do this. (Walkthrough)

Rate Create an ocx (create a control) from VB to put in your own applications. This is an example on how



Walkthrough to create your own ocx files
    By Jessy Butzke


Hey it's me again and I wanted to tell you how to create your own ocx files.
In this example we will create an ocx file that will put the word hello into
a text box within a control.

Step 1.
Open up VB and select Active X Control from the list.
(This will open up a form without a caption bar.)

Step 2.
Put a command button and textbox onto the form (Active X Control)

Step 3.
Copy the code below: and paste into your Active X Control Project



Option Explicit
Event OnFocus()

Public Property Let BoxText(ByVal Word As String)
     Text1.Text$ = Word$
End Property

Public Property Get BoxText() As String
     BoxText$ = Text1.Text
End Property

Private Sub Command1_Click()
     Me.BoxText = "Hello"
End Sub

Private Sub Text1_GotFocus()
     RaiseEvent OnFocus
End Sub



NOTE: BoxText Will Set a value into the text box and retrieve what's in the
      textbox.
NOTE: BoxText will also be located in the properties window when you use this
      control in a Standard Exe project.

Step 4.
After you have put this code with textbox and command button into
        the Active X control, Click on File then "Make *.OCX" 
        (* is the name of your ocx)

Step 5.
Open up a new VB project and select the Standard Exe icon from the menu.

Step 6.
Click on Project and then onto components and select this ocx file
from this list after you click on browse.

NOTE: You will now have this control in your VB Project.

NOTE: If you want to learn more about creating your very own control,
      E-Mail me at [email protected] and I will help. Other 
      information includes:
      if, from within VB you want the About property to bring up an about
      box just like a real OCX file, or if you want a custom property to set
      at design time.

Download this snippet    Add to My Saved Code

Create an ocx (create a control) from VB to put in your own applications. This is an example on how Comments

No comments have been posted about Create an ocx (create a control) from VB to put in your own applications. This is an example on how. Why not be the first to post a comment about Create an ocx (create a control) from VB to put in your own applications. This is an example on how.

Post your comment

Subject:
Message:
0/1000 characters