Results 1 to 15 of 15

Thread: [RESOLVED] help abt Active X controls

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Resolved [RESOLVED] help abt Active X controls

    Hi,

    I hv read a line.."Create a method of the ClassBookList control"Class Book List is the name of the Active X control which is to be created.I m unable to understand that how to create a method of any control..Methods are created for the classes bt can they be created for control?n if so thn plzz guide me how?

    Regards,

  2. #2
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: help abt Active X controls

    VB.NET MVP 2008 - Present

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Re: help abt Active X controls

    Quote Originally Posted by HanneSThEGreaT
    Thankx for your reply.But this article didn't help how to add a method of the Active X conrtol in vb 6.Can u please guide?

  4. #4
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: help abt Active X controls

    A method is simply a Public Sub or Function of your control.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Re: help abt Active X controls

    Quote Originally Posted by pnish
    A method is simply a Public Sub or Function of your control.
    But till now I just created methods of classes using a class builder utility.so how can I build a method of the control?

    i tried to write the code in the declaration as:

    public ShowAbout()

    is it correct??

    Thankx for ur help

  6. #6
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: help abt Active X controls

    Yep. But you need to specify whether it's a Sub or a Function.
    Public Sub ShowAbout()
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Re: help abt Active X controls

    Quote Originally Posted by pnish
    Yep. But you need to specify whether it's a Sub or a Function.
    Public Sub ShowAbout()
    yah It worked.Please tell me that how to add properties of a control using property procedure?

  8. #8
    Hyperactive Member BillGeek's Avatar
    Join Date
    Jun 2006
    Location
    Canada
    Posts
    440

    Re: help abt Active X controls

    Add the following to the Declerations section of the UserControl: (Decleration section - above all other code)
    VB Code:
    1. Private m_varMyProperty As String

    Now add the following anywhere in the code:
    VB Code:
    1. Public Property Let MyProperty(cValue As String)
    2.     m_varMyProperty = cValue
    3. End Property
    4. Public Property Get MyProperty() As String
    5.     MyProperty = m_varMyProperty
    6. End Property

    So in the project using the usercontrol, you can do the following:

    VB Code:
    1. MyControl.MyProperty = "Test"
    2. 'OR
    3. Dim cTest As String
    4. cTest = MyControl.MyProperty

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Re: help abt Active X controls

    Quote Originally Posted by BillGeek
    Add the following to the Declerations section of the UserControl: (Decleration section - above all other code)
    VB Code:
    1. Private m_varMyProperty As String

    Now add the following anywhere in the code:
    VB Code:
    1. Public Property Let MyProperty(cValue As String)
    2.     m_varMyProperty = cValue
    3. End Property
    4. Public Property Get MyProperty() As String
    5.     MyProperty = m_varMyProperty
    6. End Property

    So in the project using the usercontrol, you can do the following:

    VB Code:
    1. MyControl.MyProperty = "Test"
    2. 'OR
    3. Dim cTest As String
    4. cTest = MyControl.MyProperty
    thankx for the help.It worked.Is there any wizard available to build properties of Controls as using Class library componenet we can build properties for the classes?

  10. #10

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Re: help abt Active X controls

    Quote Originally Posted by BillGeek
    Yip. Go to Add-Ins, make sure that the "Control Interface Wizard" is enabled. This is the "class-builder" for ActiveX controls.
    yah ok i got it..Thankx for your reply

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Re: help abt Active X controls

    Can you please tell me how to make the objects of Active X Control?n how its properties can be accessed?

    Ragards,

  13. #13
    Hyperactive Member BillGeek's Avatar
    Join Date
    Jun 2006
    Location
    Canada
    Posts
    440

    Re: help abt Active X controls

    What do you mean by "Objects"? If you mean, for example, exposing the properties of a button, you can add properties as shown in post #8 and apply them to your button. Example:
    VB Code:
    1. Private m_varButtonCaption As String
    2. Public Property Let ButtonCaption(cValue As String)
    3.     m_varButtonCaption = cValue
    4.     CommandButton1.Caption = m_varButtonCaption
    5. End Property
    6. Public Property Get ButtonCaption() As String
    7.     ButtonCaption = m_varButtonCaption
    8. End Property
    If this is not what you want, just shout.

    PS: This is the only way known that you can actually change the properties of controls on a user control.

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Re: help abt Active X controls

    Quote Originally Posted by BillGeek
    What do you mean by "Objects"? If you mean, for example, exposing the properties of a button, you can add properties as shown in post #8 and apply them to your button. Example:
    VB Code:
    1. Private m_varButtonCaption As String
    2. Public Property Let ButtonCaption(cValue As String)
    3.     m_varButtonCaption = cValue
    4.     CommandButton1.Caption = m_varButtonCaption
    5. End Property
    6. Public Property Get ButtonCaption() As String
    7.     ButtonCaption = m_varButtonCaption
    8. End Property
    If this is not what you want, just shout.

    PS: This is the only way known that you can actually change the properties of controls on a user control.
    By objects I mean as for example objects are created for classes to access thier member functions and data members.Then how to create the objects of a control in order to access its properties?

  15. #15

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