Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Adding a Property to ActiveX Control

Posted on 1998-08-30
7
Medium Priority
?
156 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

730 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