Solved

Adding a Property to ActiveX Control

Posted on 1998-08-30
7
150 Views
Last Modified: 2010-04-30
I would like to add a  property to my ActiveX control. ( For Ex. Functionality should be just like Format property of MaskEdit control) How can i add it?
0
Comment
Question by:Anjaneyulu
7 Comments
 

Author Comment

by:Anjaneyulu
Comment Utility
Edited text of question
0
 
LVL 4

Expert Comment

by:mcix
Comment Utility
The simplest way is to use the ActiveX Control Interface Wizard Add-In that is provided with Visual Basic.  This will provide a function stub in the ctl project.

From there it is a matter of actually writing the code to do what the format property does.  Off the top of my head, I can't remember all of the masking that is supported...

But basically you would have a RawData property, which would be the unformatted Text and a Format Property which would be the Format you want to mask the RawData with.  As the User types in the textbox, you would Update the TextBox.Text property with the result of the mask...
0
 
LVL 1

Expert Comment

by:disha
Comment Utility
Hi,
If u'r activex control is made up of some control of which u want u use thr property then u can just goto user control wizard and select the property. If u want to create a new property then u just have to write a new property in u'r wizard and specify the data type. Then in the code u can serach for the GET and LET procedures of the property and manipulate the code. Also u cant use the proerty in required events to get the affect of it.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:Anjaneyulu
Comment Utility
i can add a  property to activeX control as refered by disha.But what i want is i would like to add format  type property.I got uneditable list of values using datatype Enum what i want is i want to edit it(i want to add new values at design time).
0
 
LVL 3

Accepted Solution

by:
HATCHET earned 200 total points
Comment Utility
If what you're asking is how to create different types of user-defined properties for your ActiveX control, I can help you out further with that.  Just specify what exactly you want the properties to do or what you want them to specify/change.

If what you're asking is how to change Enumeration variables at Run-Time (Design-Time of the .EXE project you're working on using your compiled ActiveX control), you can't do it.  You have to specify the values of the Enum at Design-Time of the ActiveX control before compiling it.  Below is what VB 5 Help file has to say about it :


" Enumeration variables are variables declared with an Enum type. Both variables and parameters can be declared with an Enum type. The elements of the Enum type are initialized to constant values within the Enum statement. The assigned values can't be modified at run time and can include both positive and negative numbers. For example:

Enum SecurityLevel
      IllegalEntry = -1
      SecurityLevel1 = 0
      SecurityLevel2 = 1
End Enum  "
0
 

Author Comment

by:Anjaneyulu
Comment Utility
hello hatchet, i think u have used maskedit control.what i want is i would like to add format property to  my own control(ordinary  textbox) .which will contain some standard date/time formats and if user wants other than existing formats he can add new format.Now i am unable to add new format because i used Enum datype.how can i add this?

0
 
LVL 3

Expert Comment

by:HATCHET
Comment Utility
Well, lemme tell you how to go about it and you can play with it.  I really can't do much more without making the ActiveX control for you.  =)

1) Start an ActiveX Control project and add a standard Text Box and a Timer Control to it.

2) Put code in the Change Event (Text1_Change) that checks the format of the text (Text1.Text) entered in your control to make sure it's the right format.  For example, if the format that you want to restrict to is MM/DD/YY then check that the first two characters of the text entered are numbers using the IsNumeric() function, check that the third character is the "/" character, and so on.

3) The reason I said to add a timer control is that you may want to add a function to it where if you specify a Property in the Property Window it will update the time every second in your control.  To do this, set the Interval (Timer1.Interval) of the Timer Control to 1000 (milliseconds) and in the Timer Event (Timer1_Timer) have it update the text (Text1.Text) of your Text Box to the current Time.

How you design this and how you want it to act is completely up to you.  It all depends on how you want the user to be able to use it and how you want the user not to be able to use it.  To get you started, here's two bits of code for two of the things I mentioned above:


Private Sub Text1_Change()

  Dim MyCounter As Integer
  Dim LeftChar As String
  Dim RightChar As String
 
  For MyCounter = 0 To Len(Text1.Text)
    LeftChar = Left(Text1.Text, MyCounter)
    RightChar = Right(LeftChar, 1)
    If IsNumeric(RightChar) = False Or RightChar <> "/" Then
      ' Entry Invalid - Write routine here that corrects it or
      ' gives error message
    End If
  Next

End Sub


Private Sub Timer1_Timer()

  Text1.Text = Time

End Sub


This should answer your question sufficiently.  Please assign the points.  Thanks, and good luck.

HATCHET
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now