LarsBernstorff:
Your approach only Works in the given form object, not the referenced object (testobj).
I really need to set the timerinterval from the object that is called in the form.
Actually, from what you've shared with us, it's quite understandable that we'd assume they are the same. You have shown you have a
testobj
object created within (and explicitly scoped to) your Form's
Load event procedure. From your question it seems clear you intended to use that as some derivative of the Form object and there's nothing to indicate any other Form's involved. So, bearing in mind what they were working with, Twinny's response was perfectly appropriate. As I'll explain later in the post, you'll need to write your questions more clearly if you want the answers to be more helpful. Please understand this is intended as guidance rather than criticism. As I say below, getting such things right first time is very rare.
We're having a little difficulty here understanding what you're trying to achieve and what currently doesn't work. That's quite usual. Most members struggle to explain their situations clearly. I can't begin to explain how important that is for the effectiveness of these forums.
In this case we don't have any explanation of what
testobj
is and how it's been defined. Nor do we have any indication of what it is that you've tried already that hasn't worked for you. In the absence of these it's quite likely we'll waste all of our time (Time of all of us) making suggestions, that are the obvious ones, that you've already tried. However, for now I'll make some guesses and suggest something.
I guess the
testobj
is actually some form of object based on a standard Form object. If that's true then I'm not sure how much sense it makes to create a Form (or derivative) instance within the instance itself. We have no idea of your thinking on this one so I'll leave that with you to ponder. I can't imagine a scenario where that makes sense, but maybe there is one. I can't say. It's very hard to prove a negative in such a situation.
The first thing that springs to mind is that while you've created a
testobj
instance, you've not set it to anything. It's created but essentially empty of any info. From here it looks like you may have intended this instance to be some form of reflection of the current Form, but that's not what the code does.
So, it seems there are two major flaws that you need to deal with before you can make any headway :
- Review and fix the scope of the instance of
testobj
. If you want it to survive beyond the natural life of the Form itself then I would declare it as Public in a Standard Module somewhere. - Set the instance of
testobj
such that it reflects an actual Form instance. Only when it reflects the desired Form instance will it have any effect when you set both the OnTimer
and TimerInterval
properties.
If you need further help from us here then you should also consider explaining your question further and show us what it is you're working with.
Best of luck and welcome to Bytes.