Hi everyone,
My questio is about VB6 .....
I want to declare a ActiveX object in the source instead of "drag and drop" a ActiveX object into the form. Let's say, I want to declare a timer dynamatically at run time, so I want a way to decalre a timer in the source. I found code from the other forums seem to do the job but it would not compile for me:
Dim withevents my_timer as timer 'Or
Private withevents my_timer as timer
'In form_load()
set my_timer = new timer () <---- this line would not compile
Any idea
Thanks
Kit

How to declare activeX object in source code instead on the form?
DallasSteve
http://www.developer.com/net/vb/article.php/1541411 this article talks about the similar technique I was trying to use...
looks like that way of declaring activeX control is only available in "class" not "form" ...
To duck thing,
I did make the timer declaration working long time ago but i did not have the code anymore. so I am not sure the one I used was from Win API or was it a activeX object.
my ultimate goal is to declare a MSCOMM in a DLL project. I wonder is it possible to achieve...
SneakerXZ
===
Are you trying to create an ActiveX component
==
Yes
Dim withevents my_comm as mscomm 'Or
Private withevents my_comm as mscomm
'In form_load()
set my_comm = new mscomm () <---- this line would not compile
It did not work , so I was wondering what I am missing. I still have not a chance to run this code in a dll project though
Khookie
(This probably should be moved elsewhere as it doesn't strictly apply to VBA, but the concept is the same.)
There are a couple possibilities here:
1.) You haven't set a reference to the Timer DLL.
2.) You have done [1] but the control isn't licensed.
Since you say you're working in VB6 and I assume it's a licensed installation, I'll guess the issue is #1.
If the only COM object you need to work with in this context is a Timer, I'd suggest just using the Windows API to set your timer. Basically you just need to create the timer, set its properties, and define a callback function for the Tick event. Then you can start and stop it through the API without needing to worry about ActiveX implementation.
Yes, I know, another duck thing post suggesting "use the API"
... if you're having specific troubles, feel free to shoot me an email.
Keith Chapman
What do you mean when you say "declare a MSCOMM in a DLL project"
Are you trying to create an ActiveX component