423,311 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,311 IT Pros & Developers. It's quick & easy.

Change property in open (active) form from object

P: 2
Hi All,

I have an issue here, which I would like som help solving.

1. Im opening a form [TheActiveWorkingForm].
2. In Form_load I reference an object
Expand|Select|Wrap|Line Numbers
  1. Dim obj as testobj
  2. set obj= new testobj
3. In the referenced object (testobj) I would like to set the timerInterval=200000 on [TheActiveWorkingForm].
4. Returning from the reference object (testobj) to the form [TheActiveWorkingForm].
5. When the 200 seconds has elapsed, then the timer should trigger its event.

My problem is that It seems that I cant set the timerinterval =200000 from testobj

Thanks in advance
Apr 10 '18 #1
Share this Question
Share on Google+
3 Replies


twinnyfo
Expert Mod 2.5K+
P: 2,532
Lars,

Welcome to Bytes!

I am not sure why you are declaring an object and trying to set the Timer Interval that way. You may simply set the form's own timer interval with this language:

Expand|Select|Wrap|Line Numbers
  1. Me.TimerInterval = 200000
Hope this hepps!
Apr 10 '18 #2

P: 2
This functionality you present is exactly what I wish to avoid.
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.
Thanks anyway
Apr 10 '18 #3

NeoPa
Expert Mod 15k+
P: 30,996
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 :
  1. 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.
  2. 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.
Apr 10 '18 #4

Post your reply

Sign in to post your reply or Sign up for a free account.