[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,
Re: help abt Active X controls
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?
Re: help abt Active X controls
A method is simply a Public Sub or Function of your control.
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
Re: help abt Active X controls
Yep. But you need to specify whether it's a Sub or a Function.
Public Sub ShowAbout()
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?
Re: help abt Active X controls
Add the following to the Declerations section of the UserControl: (Decleration section - above all other code)
VB Code:
Private m_varMyProperty As String
Now add the following anywhere in the code:
VB Code:
Public Property Let MyProperty(cValue As String)
m_varMyProperty = cValue
End Property
Public Property Get MyProperty() As String
MyProperty = m_varMyProperty
End Property
So in the project using the usercontrol, you can do the following:
VB Code:
MyControl.MyProperty = "Test"
'OR
Dim cTest As String
cTest = MyControl.MyProperty
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:
Private m_varMyProperty As String
Now add the following anywhere in the code:
VB Code:
Public Property Let MyProperty(cValue As String)
m_varMyProperty = cValue
End Property
Public Property Get MyProperty() As String
MyProperty = m_varMyProperty
End Property
So in the project using the usercontrol, you can do the following:
VB Code:
MyControl.MyProperty = "Test"
'OR
Dim cTest As String
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?
Re: help abt Active X controls
Yip. Go to Add-Ins, make sure that the "Control Interface Wizard" is enabled. This is the "class-builder" for ActiveX controls.
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
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,
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:
Private m_varButtonCaption As String
Public Property Let ButtonCaption(cValue As String)
m_varButtonCaption = cValue
CommandButton1.Caption = m_varButtonCaption
End Property
Public Property Get ButtonCaption() As String
ButtonCaption = m_varButtonCaption
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.
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:
Private m_varButtonCaption As String
Public Property Let ButtonCaption(cValue As String)
m_varButtonCaption = cValue
CommandButton1.Caption = m_varButtonCaption
End Property
Public Property Get ButtonCaption() As String
ButtonCaption = m_varButtonCaption
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?
Re: help abt Active X controls
Well, you just define them as Public. Example, Member Functions:
VB Code:
Public Function myFunc() As Variant
End Function