Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Adding a Property to ActiveX Control

Posted on 1998-08-30
7
Medium Priority
?
158 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
ID: 1431896
Edited text of question
0
 
LVL 4

Expert Comment

by:mcix
ID: 1431897
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
ID: 1431898
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Anjaneyulu
ID: 1431899
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 400 total points
ID: 1431900
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
ID: 1431901
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
ID: 1431902
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

824 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