Search the web
Sign In
New User? Sign Up
helpwithvb · A group for those who need help with Visual Basic
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Messages 22699 - 22728 of 22728   Newest  |  < Newer  |  Older >  |  Oldest
Messages: Show Message Summaries   (Group by Topic) Sort by Date v  
#22728 From: "Steve Manser" <smanser@...>
Date: Thu Dec 24, 2009 8:36 pm
Subject: RE: A Xmas puzzle - the infuriating timer object
tileguy2929
Offline Offline
Send Email Send Email
 
Brian,

>>> This is about nothing but timer interval.
>>> Within a Timer's own code, you can disable
>>> the timer altogether on the happening of
>>> an external event and that stops the timer.
>>>
>>> What I'm saying is that if instead, you try
>>> in an equally simple way to change
>>> its interval, it doesn't work.

>>> ....so there's no logical reason why it can't
>>> change its own interval. If you can do it,
>>> make my Christmas by telling me how.


You have me there, as I didn't Fire-Up VB-6
to check what I was coding in the e-mail.

You are asking for a means of changing the
Timer's Interval value from within the
Timer's Timer Sub Routine ?

I fired up VB-6.

Hey, I think I just made your Christmas  :)

Have you tried to do this ?

In a new project, clean sheet, on the form
place a Timer control, 4 labels, and a Button.

Use this code:

( I sent the code to Brian in a Text File )

Everyone else can have a zipped copy of the
VB-6 Project just by dropping me an e-mail
and wishing me a happy greeting, etc.

...and, Yes, by some lucky chance of good fortune
I was able to make the Timer control do what
Brian wanted to do, and if he can read my
code he might find something that helps.

However, reading my code might be a bigger chore  :)

Happy Holidays, and a very Merry Christmas,

Steve

________________________________

From: helpwithvb@yahoogroups.com
  On Behalf Of Brian Shieldhouse
Sent: Thursday, December 24, 2009 12:35 PM
To: helpwithvb@yahoogroups.com
Subject: Re: [helpwithvb] A Xmas puzzle
          - the infuriating timer object


I can't find it at the moment, Tim, as I gave up and
incorporated an additional timer to give interval
instructions to the first one - an obvious lazy solution.

But I'm not chickening out. Over the next day or so,
I can probably find it, and, if not I'm fairly sure
I can reconstruct it.

I'll just say for completeness that I'm using VB5
Learning Edition but I think I read somewhere that
it's virtually the same as VB5 Professional.

/Brian

#22727 From: "Brian Shieldhouse" <brian_shieldhouse@...>
Date: Thu Dec 24, 2009 5:35 pm
Subject: Re: A Xmas puzzle - the infuriating timer object
brianshieldh...
Offline Offline
Send Email Send Email
 
I can't find it at the moment, Tim, as I gave up and incorporated an additional timer to give interval instructions to the first one - an obvious lazy solution.  
 
But I'm not chickening out. Over the next day or so, I can probably find it, and, if not I'm fairly sure I can reconstruct it.
 
I'll just say for completeness that I'm using VB5 Learning Edition but I think I read somewhere that it's virtually the same as VB5 Professional.
 
/Brian

Sent: Thursday, December 24, 2009 6:13 PM
Subject: RE: [helpwithvb] A Xmas puzzle - the infuriating timer object

 

It works fine for me Brian…why else is the interval method of the timer object specified??

I don’t know the  VB5/VB6 issues, but using VB.NET I can change the timer interval on the fly without stopping the timer.

Please tell us why you think it’s not working.

Show us your code please.

/tr

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Brian Shieldhouse
Sent: Thursday, December 24, 2009 10:21 AM
To: helpwithvb@yahoogroups.com
Subject: Re: [helpwithvb] A Xmas puzzle - the infuriating timer object

 

Reply to Kenneth: Yes. Thanks. That certainly works but, unless I'm losing my marbles, I've always got it to work before, without ever using the 'Static' keyword. (OK. I'm losing my marbles. Winking smile emoticon End of thread. )

Reply to Tim (Changing timer interval in code during timer's operation): There is a misunderstanding here. Forget about variables and their values. This is about nothing but timer interval. Within a Timer's own code, you can disable the timer altogether on the happening of an external event and that stops the timer.

What I'm saying is that if instead, you try in an equally simple way to change its interval, it doesn't work.

I've just read what Steve's written and. as usual, he's gone to a lot of trouble, but I don't think that affects what I've just written.

/Brian

Sent: Thursday, December 24, 2009 1:56 PM

Subject: Re: [helpwithvb] A Xmas puzzle - the infuriating timer object


You would have to set "X" static

Static x As Long

x = x + 1
Text1.Text = x

-----Original Message-----
From: Brian Shieldhouse brian_shieldhouse@hotmail.com
Sent 12/24/2009 7:06:39 AM
To: helpwithvb helpwithvb@yahoogroups.com
Subject: [helpwithvb] A Xmas puzzle - the infuriating timer object

Heading for a boring Christmas ? Then make it a frustrating one instead, by trying this with a textbox:

Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
x= x + 1
Text1.Text = x
End Sub

Shouldn't the textbox value keep incrementing ?

Feel like even more Xmas masochism ? We know that timer object code can turn its timer off, so there's no logical reason why it can't change its own interval. If you can do it, make my Christmas by telling me how. (All VB Help says is:"The interval's countdown always starts from the value of its interval property setting")

Merry Christmas,

Brian

www.briansbok.webs.com
"Svart Moln ver Sverige" nu tillgnglig !
Ls Kap.1 online

www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online


#22726 From: "Timothy Rupp" <tim.rupp@...>
Date: Thu Dec 24, 2009 5:13 pm
Subject: RE: A Xmas puzzle - the infuriating timer object
timrupp804
Offline Offline
Send Email Send Email
 

It works fine for me Brian…why else is the interval method of the timer object specified??

 

I don’t know the  VB5/VB6 issues, but using VB.NET I can change the timer interval on the fly without stopping the timer.

 

Please tell us why you think it’s not working.

 

Show us your code please.

 

/tr

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Brian Shieldhouse
Sent: Thursday, December 24, 2009 10:21 AM
To: helpwithvb@yahoogroups.com
Subject: Re: [helpwithvb] A Xmas puzzle - the infuriating timer object

 

 

Reply to Kenneth: Yes. Thanks. That certainly works but, unless I'm losing my marbles, I've always got it to work before, without ever using the 'Static' keyword. (OK. I'm losing my marbles. Winking smile emoticon End of thread. )

 

Reply to Tim (Changing timer interval in code during timer's operation): There is a misunderstanding here. Forget about variables and their values. This is about nothing but timer interval. Within a Timer's own code, you can disable the timer altogether on the happening of an external event and that stops the timer.

 

What I'm saying is that if instead, you try in an equally simple way to change its interval, it doesn't work.

 

I've just read what Steve's written and. as usual, he's gone to a lot of trouble, but I don't think that affects what I've just written.

 

/Brian

 

Sent: Thursday, December 24, 2009 1:56 PM

Subject: Re: [helpwithvb] A Xmas puzzle - the infuriating timer object


You would have to set "X" static

Static x As Long

x = x + 1
Text1.Text = x

-----Original Message-----
From: Brian Shieldhouse brian_shieldhouse@...
Sent 12/24/2009 7:06:39 AM
To: helpwithvb helpwithvb@yahoogroups.com
Subject: [helpwithvb] A Xmas puzzle - the infuriating timer object

Heading for a boring Christmas ? Then make it a frustrating one instead, by trying this with a textbox:

Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
x= x + 1
Text1.Text = x
End Sub

Shouldn't the textbox value keep incrementing ?

Feel like even more Xmas masochism ? We know that timer object code can turn its timer off, so there's no logical reason why it can't change its own interval. If you can do it, make my Christmas by telling me how. (All VB Help says is:"The interval's countdown always starts from the value of its interval property setting")

Merry Christmas,

Brian

www.briansbok.webs.com
"Svart Moln ver Sverige" nu tillgnglig !
Ls Kap.1 online

www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online


#22725 From: "Brian Shieldhouse" <brian_shieldhouse@...>
Date: Thu Dec 24, 2009 3:20 pm
Subject: Re: A Xmas puzzle - the infuriating timer object
brianshieldh...
Offline Offline
Send Email Send Email
 
Reply to Kenneth: Yes. Thanks. That certainly works but, unless I'm losing my marbles, I've always got it to work before, without ever using the 'Static' keyword. (OK. I'm losing my marbles. Winking smile emoticon End of thread. )
 
Reply to Tim (Changing timer interval in code during timer's operation): There is a misunderstanding here. Forget about variables and their values. This is about nothing but timer interval. Within a Timer's own code, you can disable the timer altogether on the happening of an external event and that stops the timer.
 
What I'm saying is that if instead, you try in an equally simple way to change its interval, it doesn't work.
 
I've just read what Steve's written and. as usual, he's gone to a lot of trouble, but I don't think that affects what I've just written.
 
/Brian
 
Sent: Thursday, December 24, 2009 1:56 PM
Subject: Re: [helpwithvb] A Xmas puzzle - the infuriating timer object

You would have to set "X" static

Static x As Long

x = x + 1
Text1.Text = x

-----Original Message-----
From: Brian Shieldhouse brian_shieldhouse@hotmail.com
Sent 12/24/2009 7:06:39 AM
To: helpwithvb helpwithvb@yahoogroups.com
Subject: [helpwithvb] A Xmas puzzle - the infuriating timer object

Heading for a boring Christmas ? Then make it a frustrating one instead, by trying this with a textbox:

Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
x= x + 1
Text1.Text = x
End Sub

Shouldn't the textbox value keep incrementing ?

Feel like even more Xmas masochism ? We know that timer object code can turn its timer off, so there's no logical reason why it can't change its own interval. If you can do it, make my Christmas by telling me how. (All VB Help says is:"The interval's countdown always starts from the value of its interval property setting")

Merry Christmas,

Brian

www.briansbok.webs.com
"Svart Moln ver Sverige" nu tillgnglig !
Ls Kap.1 online

www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online


#22724 From: "Steve Manser" <smanser@...>
Date: Thu Dec 24, 2009 2:46 pm
Subject: RE: A Xmas puzzle - the infuriating timer object
tileguy2929
Offline Offline
Send Email Send Email
 
>>  But VB presumably assumes it's
>>  an integer with a value of 0

Your code is telling us that your first
line of code in your form module is not

Option Explicit

Your 'X' is Local in Scope,
Local to the Sub Routine where it was created,
and Tim was looking to see if you had
Declared 'X' as a module-wide variable,
or as some Global variable.

I'm sure Tim was also trying to make you
ask yourself some other questions
as you explore this problem.

You did not 'Dim' the variable 'X'
you declared it on the fly...

Any variable in VB-5/6 that is not declared
will be seen by VB-5/6 as a Variant Data Type
and not as an Integer or Long Data Type.

In our minds we may see a Variable as a Long Type
but if we don't follow the rules VB-5/6 will do
the Default Thing and declare it as a Variant.

As always, VB.AnyFlavor does not have ESP.

Just as Kenneth explained,  your 'X' should
be declared using the Static keyword
so that VB knows it should retain its
stored value between calls to this routine.

Note that

X = 1  assigns an Integer into X

X = 1& assigns a Long Value of 1 into X

Option Explicit  <-- always your first line of code

Private Sub MyTimerName_Timer()
Static X   As Long

X = X + 1&

Text1.Text = Format$(X)  or  CStr(X)

If X = 5& Then
    '
    X = 0&
    MyTimerName.Enabled = False
    Call ChangeMyTimerInterval(Me.MyTimerName, 100&)
End If

End Sub

In another module, perhaps a BAS file for Utilities:

Option Explicit

Public Sub ChangeMyTimerInterval(ByRef MTN As Timer, _
                            ByRef New_Interval As Long)

    MTN.Interval = New_Interval

End Sub

We can control all 42 Timers on our Form:

Public Sub EnableMyTimer(ByRef MTN As Timer, _
                 ByRef EnabledValue As Boolean)

MTN.Enabled = EnabledValue

End Sub

This is all Air-Code, so you may find that
you need a more explicit declare for the
Timer Control in the Public Routine.

I've miss-placed that bit in my brain, but
it may be something like   VBXXXXOCX.Timer

But, it probably will work as written, maybe  :)



All The Best of The Holidays to Everyone,

Steve

________________________________

From: helpwithvb@yahoogroups.com
On Behalf Of Brian Shieldhouse
Sent: Thursday, December 24, 2009 7:54 AM
To: helpwithvb@yahoogroups.com
Subject: Re: [helpwithvb] A Xmas puzzle - the infuriating timer object




Hi Tim, I didn't set a scope as I wanted to keep the code as short and
simple as possible for email purposes..

But VB presumably assumes it's an integer with a value of 0, because when
you click on the command button, a "1" appears in the textbox after a
second, showing that the timer has done its job in incrementing 0 to 1 but,
for some obscure reason, only for one interval) . I expected that figure to
increment every second but it doesn't change.

I know it has incremented in other similar programs but I can't see why it
doesn't in that one. I'd expect it to either work as intended, or not to
work at all.

Don't forget the other query. I think that's more intriguing. Winking smile
emoticon

/Brian

From: Timothy Rupp <mailto:tim.rupp@...>
Sent: Thursday, December 24, 2009 1:20 PM
To: helpwithvb@yahoogroups.com <mailto:helpwithvb@yahoogroups.com>
Subject: RE: [helpwithvb] A Xmas puzzle - the infuriating timer object



What is the scope of your variable x?

/tr

From: helpwithvb@yahoogroups.com
On Behalf Of Brian Shieldhouse
Sent: Thursday, December 24, 2009 7:07 AM
To: helpwithvb
Subject: [helpwithvb] A Xmas puzzle - the infuriating timer object



Heading for a boring Christmas ?
Then make it a frustrating one instead,
by trying this with a textbox:

Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
x = x + 1
Text1.Text = x
End Sub

Shouldn't the textbox value keep incrementing ?

Feel like even more Xmas masochism ? We know that timer object code can turn
its timer off, so there's no logical reason why it can't change its own
interval. If you can do it, make my Christmas by telling me how. (All VB
Help says is:"The interval's countdown always starts from the value of its
interval property setting")

Merry Christmas,

Brian
.
.

#22723 From: "Timothy Rupp" <tim.rupp@...>
Date: Thu Dec 24, 2009 1:52 pm
Subject: RE: A Xmas puzzle - the infuriating timer object
timrupp804
Offline Offline
Send Email Send Email
 

My question was asked to be informative. However, I think you missed the point.

 

Your timer enters its routine on the interval and only then does your variable come into scope. When you leave the routine, the variable goes out of scope and is cleared. Thus every time you enter the timer routine you are back at a zero value for x. If you make the scope of your variable program wide rather than routine wide, it will act just as expect.

 

And your query is without meaning. You have already set your timer interval in the program. I believe your confusion is caused by the scoping of your variable.

 

/tr

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Brian Shieldhouse
Sent: Thursday, December 24, 2009 7:54 AM
To: helpwithvb@yahoogroups.com
Subject: Re: [helpwithvb] A Xmas puzzle - the infuriating timer object

 

 

Hi Tim, I didn't set a scope as I wanted to keep the code as short and simple as possible for email purposes..

 

But VB presumably assumes it's an integer with a value of 0, because when you click on the command button, a "1" appears in the textbox after a second, showing that the timer has done its job in incrementing 0 to 1 but, for some obscure reason, only for one interval) . I expected that figure to increment every second but it doesn't change.

 

I know it has incremented in other similar programs but I can't see why it doesn't in that one. I'd expect it to either work as intended, or not to work at all.

 

Don't forget the other query. I think that's more intriguing. Winking smile emoticon

 

/Brian

 

From: Timothy Rupp

Sent: Thursday, December 24, 2009 1:20 PM

Subject: RE: [helpwithvb] A Xmas puzzle - the infuriating timer object

 

 

What is the scope of your variable x?

/tr

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Brian Shieldhouse
Sent: Thursday, December 24, 2009 7:07 AM
To: helpwithvb
Subject: [helpwithvb] A Xmas puzzle - the infuriating timer object

 

Heading for a boring Christmas ? Then make it a frustrating one instead, by trying this with a textbox: 

Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
x = x + 1
Text1.Text = x
End Sub 

Shouldn't the textbox value keep incrementing ?

Feel like even more Xmas masochism ? We know that timer object code can turn its timer off, so there's no logical reason why it can't change its own interval. If you can do it, make my Christmas by telling me how. (All VB Help says is:"The interval's countdown always starts from the value of its interval property setting")

Merry Christmas,

Brian

www.briansbok.webs.com
"Svart Moln över Sverige" nu tillgänglig !
Läs Kap.1 online
>>>>>>>>>>>>>
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online


#22722 From: "Kenneth Danner" <kwd@...>
Date: Thu Dec 24, 2009 12:56 pm
Subject: Re: A Xmas puzzle - the infuriating timer object
racermand289
Offline Offline
Send Email Send Email
 
You would have to set "X" static

Static x As Long

x = x + 1
Text1.Text = x

-----Original Message-----
From: Brian Shieldhouse brian_shieldhouse@...
Sent 12/24/2009 7:06:39 AM
To: helpwithvb helpwithvb@yahoogroups.com
Subject: [helpwithvb] A Xmas puzzle - the infuriating timer object





Heading for a boring Christmas ? Then make it a frustrating one instead, by
trying this with a textbox:



Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub



Private Sub Timer1_Timer()
x= x + 1
Text1.Text = x
End Sub


Shouldn't the textbox value keep incrementing ?



Feel like even more Xmas masochism ? We know that timer object code can turn its
timer off, so there's no logical reason why it can't change its own interval. If
you can do it, make my Christmas by telling me how. (All VB Help says is:"The
interval's countdown always starts from the value of its interval property
setting")



Merry Christmas,



Brian



www.briansbok.webs.com
"Svart Moln ver Sverige" nu tillgnglig !
Ls Kap.1 online

www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online

#22721 From: "Brian Shieldhouse" <brian_shieldhouse@...>
Date: Thu Dec 24, 2009 12:54 pm
Subject: Re: A Xmas puzzle - the infuriating timer object
brianshieldh...
Offline Offline
Send Email Send Email
 
Hi Tim, I didn't set a scope as I wanted to keep the code as short and simple as possible for email purposes..
 
But VB presumably assumes it's an integer with a value of 0, because when you click on the command button, a "1" appears in the textbox after a second, showing that the timer has done its job in incrementing 0 to 1 but, for some obscure reason, only for one interval) . I expected that figure to increment every second but it doesn't change.
 
I know it has incremented in other similar programs but I can't see why it doesn't in that one. I'd expect it to either work as intended, or not to work at all.
 
Don't forget the other query. I think that's more intriguing. Winking smile emoticon
 
/Brian
 
Sent: Thursday, December 24, 2009 1:20 PM
Subject: RE: [helpwithvb] A Xmas puzzle - the infuriating timer object

 

What is the scope of your variable x?

/tr

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Brian Shieldhouse
Sent: Thursday, December 24, 2009 7:07 AM
To: helpwithvb
Subject: [helpwithvb] A Xmas puzzle - the infuriating timer object

 

Heading for a boring Christmas ? Then make it a frustrating one instead, by trying this with a textbox: 

Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
x = x + 1
Text1.Text = x
End Sub 

Shouldn't the textbox value keep incrementing ?

Feel like even more Xmas masochism ? We know that timer object code can turn its timer off, so there's no logical reason why it can't change its own interval. If you can do it, make my Christmas by telling me how. (All VB Help says is:"The interval's countdown always starts from the value of its interval property setting")

Merry Christmas,

Brian

www.briansbok.webs.com
"Svart Moln över Sverige" nu tillgänglig !
Läs Kap.1 online
>>>>>>>>>>>>>
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online


#22720 From: "Timothy Rupp" <tim.rupp@...>
Date: Thu Dec 24, 2009 12:29 pm
Subject: RE: A Xmas puzzle - the infuriating timer object
timrupp804
Offline Offline
Send Email Send Email
 

To set a timer’s interval: Timer1.Interval = myValue just as you have in the shown snippet.

 

 

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Brian Shieldhouse
Sent: Thursday, December 24, 2009 7:07 AM
To: helpwithvb
Subject: [helpwithvb] A Xmas puzzle - the infuriating timer object

 

 

Heading for a boring Christmas ? Then make it a frustrating one instead, by trying this with a textbox: 

 

Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub

 

Private Sub Timer1_Timer()
x = x + 1
Text1.Text = x
End Sub 

Shouldn't the textbox value keep incrementing ?

 

Feel like even more Xmas masochism ? We know that timer object code can turn its timer off, so there's no logical reason why it can't change its own interval. If you can do it, make my Christmas by telling me how. (All VB Help says is:"The interval's countdown always starts from the value of its interval property setting")

 

Merry Christmas,

 

Brian

www.briansbok.webs.com
"Svart Moln över Sverige" nu tillgänglig !
Läs Kap.1 online
>>>>>>>>>>>>>
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online

 

 


#22719 From: "Timothy Rupp" <tim.rupp@...>
Date: Thu Dec 24, 2009 12:20 pm
Subject: RE: A Xmas puzzle - the infuriating timer object
timrupp804
Offline Offline
Send Email Send Email
 

What is the scope of your variable x?

 

/tr

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Brian Shieldhouse
Sent: Thursday, December 24, 2009 7:07 AM
To: helpwithvb
Subject: [helpwithvb] A Xmas puzzle - the infuriating timer object

 

 

Heading for a boring Christmas ? Then make it a frustrating one instead, by trying this with a textbox: 

 

Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub

 

Private Sub Timer1_Timer()
x = x + 1
Text1.Text = x
End Sub 

Shouldn't the textbox value keep incrementing ?

 

Feel like even more Xmas masochism ? We know that timer object code can turn its timer off, so there's no logical reason why it can't change its own interval. If you can do it, make my Christmas by telling me how. (All VB Help says is:"The interval's countdown always starts from the value of its interval property setting")

 

Merry Christmas,

 

Brian

www.briansbok.webs.com
"Svart Moln över Sverige" nu tillgänglig !
Läs Kap.1 online
>>>>>>>>>>>>>
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online

 

 


#22718 From: "Brian Shieldhouse" <brian_shieldhouse@...>
Date: Thu Dec 24, 2009 12:06 pm
Subject: A Xmas puzzle - the infuriating timer object
brianshieldh...
Offline Offline
Send Email Send Email
 
Heading for a boring Christmas ? Then make it a frustrating one instead, by trying this with a textbox: 
 
Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub
 
Private Sub Timer1_Timer()
x = x + 1
Text1.Text = x
End Sub 
Shouldn't the textbox value keep incrementing ?
 
Feel like even more Xmas masochism ? We know that timer object code can turn its timer off, so there's no logical reason why it can't change its own interval. If you can do it, make my Christmas by telling me how. (All VB Help says is:"The interval's countdown always starts from the value of its interval property setting")
 
Merry Christmas,
 
Brian
www.briansbok.webs.com
"Svart Moln över Sverige" nu tillgänglig !
Läs Kap.1 online
>>>>>>>>>>>>>
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online

 

#22717 From: "Timothy Rupp" <tim.rupp@...>
Date: Mon Dec 21, 2009 4:46 pm
Subject: RE: Delay
timrupp804
Offline Offline
Send Email Send Email
 
I didn't do exhaustive testing...but I don't think that .NET compiler does
this optimization...although it probably should.

10^6 iterations is about .0156 seconds...10^9 iterations took anywhere from
2.5 to 2.8 seconds for me. (And perhaps all of this time is due to time
slices for the OS instead of the loop itself...that I didn't test.)

/tr


-----Original Message-----
From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On
Behalf Of Neiger, Bruce D
Sent: Monday, December 21, 2009 11:04 AM
To: helpwithvb@yahoogroups.com
Subject: RE: [helpwithvb] Delay

I am fairly certain that the .NET compiler optimizes for this, as Adelle
suggests.  I also believe that it is an OLD feature, which you might have
noticed had you tried this anytime over the past half decade :).

One word about sleep api function.  IME, it seems to take over more than
just the current thread, and stops the whole process, so other things you
may be running might sleep to.  I try to avoid it, since funny interop
things can happen, and it usually doesn't prove to be the best solution.
The timer control is far better, and as you have likely noticed is fairly
straightforward to use.

-BDN


________________________________

From: helpwithvb@yahoogroups.com on behalf of Adelle Hartley
Sent: Mon 12/21/2009 6:35 AM
To: helpwithvb@yahoogroups.com
Subject: Re: [helpwithvb] Delay




Brian Shieldhouse wrote:

> *What fascinates me is that the processor seems to completely ignore
> code which says: "For j =1 to 1,000,000: Next." As logic requires that
> the processor can't possibly be ignoring it, the only explanation seems
> to be that that piece of code executes so rapidly that the brain can't
> even detect the very tiny delay it must actually produce. Can modern
> processors really be as fast as that ?*

You're the reason my old DOS games scroll too fast for me to play them
properly. Yes, CPUs have gotten faster.

Also, I would expect a modern compiler to notice that the body of the
loop is empty and that it therefore need not be executed (although, if
we're talking VB6, "modern" doesn't come into it, except for the part
about the CPU being really fast).

Adelle.

#22716 From: "Neiger, Bruce D" <Bruce.D.Neiger@...>
Date: Mon Dec 21, 2009 4:04 pm
Subject: RE: Delay
thezorch
Offline Offline
Send Email Send Email
 
I am fairly certain that the .NET compiler optimizes for this, as Adelle
suggests.  I also believe that it is an OLD feature, which you might have
noticed had you tried this anytime over the past half decade :).

One word about sleep api function.  IME, it seems to take over more than just
the current thread, and stops the whole process, so other things you may be
running might sleep to.  I try to avoid it, since funny interop things can
happen, and it usually doesn't prove to be the best solution.  The timer control
is far better, and as you have likely noticed is fairly straightforward to use.

-BDN


________________________________

From: helpwithvb@yahoogroups.com on behalf of Adelle Hartley
Sent: Mon 12/21/2009 6:35 AM
To: helpwithvb@yahoogroups.com
Subject: Re: [helpwithvb] Delay




Brian Shieldhouse wrote:

> *What fascinates me is that the processor seems to completely ignore
> code which says: "For j =1 to 1,000,000: Next." As logic requires that
> the processor can't possibly be ignoring it, the only explanation seems
> to be that that piece of code executes so rapidly that the brain can't
> even detect the very tiny delay it must actually produce. Can modern
> processors really be as fast as that ?*

You're the reason my old DOS games scroll too fast for me to play them
properly. Yes, CPUs have gotten faster.

Also, I would expect a modern compiler to notice that the body of the
loop is empty and that it therefore need not be executed (although, if
we're talking VB6, "modern" doesn't come into it, except for the part
about the CPU being really fast).

Adelle.

#22715 From: "Timothy Rupp" <tim.rupp@...>
Date: Mon Dec 21, 2009 11:41 am
Subject: RE: Delay
timrupp804
Offline Offline
Send Email Send Email
 

In answer to your question…yes modern processors are really that fast. Try it out…put a button and three labels on your form.

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim a, b As DateTime

        Dim c As TimeSpan

        a = Now

        For j = 1 To 1000000 : Next

        b = Now

        Label1.Text = a.ToString

        Label2.Text = b.ToString

        c = b - a

        Label3.Text = c.ToString

    End Sub

 

My four year old Pentium processor runs this in a bit over 0.0156 seconds which is probably imperceptible to detection by the human brain.

 

Increase the loop to 10^9 and you start to see perceptible delays…my system takes about 2.78 seconds for that.

 

Happy holidays.

 

/tr

 

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Brian Shieldhouse
Sent: Monday, December 21, 2009 5:54 AM
To: helpwithvb@yahoogroups.com
Subject: Re: [helpwithvb] Delay

 

 

Well, I haven't had time to go into it fully yet, but, yes, it looks as if the timer control will probably provide the answer. In the program, I'm already using a timer with an interval of 1 second, and, needing a delay of a full minute at one point, hadn't appreciated that the code could temporarily change the interval to as high as 60,000 milliseconds,. 

 

Another possibility might be the Dateadd function but I haven't explored that.

 

What fascinates me is that the processor seems to completely ignore code which says: "For j =1 to 1,000,000: Next." As logic requires that the processor can't possibly be ignoring it, the only explanation seems to be that that piece of code executes so rapidly that the brain can't even detect the very tiny delay it must actually produce. Can modern processors really be as fast as that ?

 

Brian

www.briansbok.webs.com
"Svart Moln över Sverige"
Läs Kap.1 online
>>>>>>>>>>>>>
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online

 

From: Timothy Rupp

Sent: Sunday, December 20, 2009 11:17 PM

Subject: RE: [helpwithvb] Delay

 

 

You can use the timer control and set the amount of time you want to wait before resuming.

/tr

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Brian Shieldhouse
Sent: Sunday, December 20, 2009 5:13 PM
To: helpwithvb
Subject: [helpwithvb] Delay

 

Can anyone tell me how to introduce pause or delay into a program ?

With pre-VB Basic, all you had to do was write: "For j=1 to 100 : next", but with VB, the program competely ignore the intended delay, however large you make that figure (e.g. 1,000,000)

Brian

www.briansbok.webs.com
"Svart Moln över Sverige"
Läs Kap.1 online
>>>>>>>>>>>>>
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online


#22714 From: Adelle Hartley <adelle@...>
Date: Mon Dec 21, 2009 12:35 pm
Subject: Re: Delay
adellehartley
Offline Offline
Send Email Send Email
 
Brian Shieldhouse wrote:

> *What fascinates me is that the processor seems to completely ignore
> code which says: "For j =1 to 1,000,000: Next." As logic requires that
> the processor can't possibly be ignoring it, the only explanation seems
> to be that that piece of code executes so rapidly that the brain can't
> even detect the very tiny delay it must actually produce. Can modern
> processors really be as fast as that ?*

You're the reason my old DOS games scroll too fast for me to play them
properly.  Yes, CPUs have gotten faster.

Also, I would expect a modern compiler to notice that the body of the
loop is empty and that it therefore need not be executed (although, if
we're talking VB6, "modern" doesn't come into it, except for the part
about the CPU being really fast).

Adelle.

#22713 From: "Brian Shieldhouse" <brian_shieldhouse@...>
Date: Mon Dec 21, 2009 10:53 am
Subject: Re: Delay
brianshieldh...
Offline Offline
Send Email Send Email
 
Well, I haven't had time to go into it fully yet, but, yes, it looks as if the timer control will probably provide the answer. In the program, I'm already using a timer with an interval of 1 second, and, needing a delay of a full minute at one point, hadn't appreciated that the code could temporarily change the interval to as high as 60,000 milliseconds,. 
 
Another possibility might be the Dateadd function but I haven't explored that.
 
What fascinates me is that the processor seems to completely ignore code which says: "For j =1 to 1,000,000: Next." As logic requires that the processor can't possibly be ignoring it, the only explanation seems to be that that piece of code executes so rapidly that the brain can't even detect the very tiny delay it must actually produce. Can modern processors really be as fast as that ?
 
Brian
www.briansbok.webs.com
"Svart Moln över Sverige"
Läs Kap.1 online
>>>>>>>>>>>>>
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online

Sent: Sunday, December 20, 2009 11:17 PM
Subject: RE: [helpwithvb] Delay

 

You can use the timer control and set the amount of time you want to wait before resuming.

/tr

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Brian Shieldhouse
Sent: Sunday, December 20, 2009 5:13 PM
To: helpwithvb
Subject: [helpwithvb] Delay

 

Can anyone tell me how to introduce pause or delay into a program ?

With pre-VB Basic, all you had to do was write: "For j=1 to 100 : next", but with VB, the program competely ignore the intended delay, however large you make that figure (e.g. 1,000,000)

Brian

www.briansbok.webs.com
"Svart Moln över Sverige"
Läs Kap.1 online
>>>>>>>>>>>>>
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online


#22712 From: Kenneth Danner <kwd@...>
Date: Sun Dec 20, 2009 11:16 pm
Subject: Re: Delay
racermand289
Offline Offline
Send Email Send Email
 

What about "Sleep"

example...

Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Call Sleep(4000)




At 05:33 PM 12/20/2009, you wrote:


Well, yes. That may provide the answer. But I'm not sure if it'll work in this context.
 
I'll try it tomorrow and report further if it doesn't. 
 
Thanks for the suggestion.
 
Brian
www.briansbok.webs.com
"Svart Moln över Sverige"
Läs Kap.1 online
>>>>>>>>>>>>>
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online

From: Timothy Rupp
Sent: Sunday, December 20, 2009 11:17 PM
To: helpwithvb@yahoogroups.com
Subject: RE: [helpwithvb] Delay

 

You can use the timer control and set the amount of time you want to wait before resuming.

/tr

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Brian Shieldhouse
Sent: Sunday, December 20, 2009 5:13 PM
To: helpwithvb
Subject: [helpwithvb] Delay

 

Can anyone tell me how to introduce pause or delay into a program ?

With pre-VB Basic, all you had to do was write: "For j=1 to 100 : next", but with VB, the program competely ignore the intended delay, however large you make that figure (e.g. 1,000,000)

Brian

www.briansbok.webs.com
"Svart Moln över Sverige"

Läs Kap.1 online
>>>>>>>>>>>>>
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online




#22711 From: "Brian Shieldhouse" <brian_shieldhouse@...>
Date: Sun Dec 20, 2009 10:33 pm
Subject: Re: Delay
brianshieldh...
Offline Offline
Send Email Send Email
 
Well, yes. That may provide the answer. But I'm not sure if it'll work in this context.
 
I'll try it tomorrow and report further if it doesn't. 
 
Thanks for the suggestion.
 
Brian
www.briansbok.webs.com
"Svart Moln över Sverige"
Läs Kap.1 online
>>>>>>>>>>>>>
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online

Sent: Sunday, December 20, 2009 11:17 PM
Subject: RE: [helpwithvb] Delay

 

You can use the timer control and set the amount of time you want to wait before resuming.

/tr

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Brian Shieldhouse
Sent: Sunday, December 20, 2009 5:13 PM
To: helpwithvb
Subject: [helpwithvb] Delay

 

Can anyone tell me how to introduce pause or delay into a program ?

With pre-VB Basic, all you had to do was write: "For j=1 to 100 : next", but with VB, the program competely ignore the intended delay, however large you make that figure (e.g. 1,000,000)

Brian

www.briansbok.webs.com
"Svart Moln över Sverige"
Läs Kap.1 online
>>>>>>>>>>>>>
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online


#22710 From: "Timothy Rupp" <tim.rupp@...>
Date: Sun Dec 20, 2009 10:17 pm
Subject: RE: Delay
timrupp804
Offline Offline
Send Email Send Email
 

You can use the timer control and set the amount of time you want to wait before resuming.

 

/tr

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Brian Shieldhouse
Sent: Sunday, December 20, 2009 5:13 PM
To: helpwithvb
Subject: [helpwithvb] Delay

 

 

Can anyone tell me how to introduce pause or delay into a program ?

 

With pre-VB Basic, all you had to do was write: "For j=1 to 100 : next", but with VB, the program competely ignore the intended delay, however large you make that figure (e.g. 1,000,000)

 

Brian

www.briansbok.webs.com
"Svart Moln över Sverige"
Läs Kap.1 online
>>>>>>>>>>>>>
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online


#22709 From: "Brian Shieldhouse" <brian_shieldhouse@...>
Date: Sun Dec 20, 2009 10:12 pm
Subject: Delay
brianshieldh...
Offline Offline
Send Email Send Email
 
Can anyone tell me how to introduce pause or delay into a program ?
 
With pre-VB Basic, all you had to do was write: "For j=1 to 100 : next", but with VB, the program competely ignore the intended delay, however large you make that figure (e.g. 1,000,000)
 
Brian
www.briansbok.webs.com
"Svart Moln över Sverige"
Läs Kap.1 online
>>>>>>>>>>>>>
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online

#22708 From: "Brian Shieldhouse" <brian_shieldhouse@...>
Date: Sun Dec 20, 2009 9:57 pm
Subject: Re: Edward Myerson is out of the office.
brianshieldh...
Offline Offline
Send Email Send Email
 
Enough of this levity ! We shouldn't assume he's on vacation. As it's clear he never sees these comments, isn't it time we reported him as missing ? 
 
Brian
www.briansbook.webs.com
"Black Cloud over Sweden"
Read Ch.1 online
>>>>>>>>>>>>>
www.briansbok.webs.com
"Svart Moln över Sverige"
Läs Kap.1 online


Sent: Sunday, December 20, 2009 10:30 PM
Subject: Re: [helpwithvb] Edward Myerson is out of the office.

 

man i wish i got paid 40-60k to have this guys vacation schedule.
 
Bryan Schulz
----- Original Message -----
Sent: Sunday, December 20, 2009 2:28 PM
Subject: [helpwithvb] Edward Myerson is out of the office.

 


I will be out of the office starting 12/19/2009 and will not return until
01/04/2010.

Have a happy holiday and healthy New Year.
If urgently needed I can be reached on my cell phone 412 759 9492 or email


#22707 From: "Bryan Schulz" <b.schulz@...>
Date: Sun Dec 20, 2009 9:30 pm
Subject: Re: Edward Myerson is out of the office.
bryan4772002
Offline Offline
Send Email Send Email
 
man i wish i got paid 40-60k to have this guys vacation schedule.
 
Bryan Schulz
----- Original Message -----
Sent: Sunday, December 20, 2009 2:28 PM
Subject: [helpwithvb] Edward Myerson is out of the office.

 


I will be out of the office starting 12/19/2009 and will not return until
01/04/2010.

Have a happy holiday and healthy New Year.
If urgently needed I can be reached on my cell phone 412 759 9492 or email


#22706 From: edward.myerson@...
Date: Sun Dec 20, 2009 8:28 pm
Subject: Edward Myerson is out of the office.
aa3xy
Offline Offline
Send Email Send Email
 
I will be out of the office starting  12/19/2009 and will not return until
01/04/2010.

Have a happy holiday and healthy New Year.
  If urgently needed I can be reached on my cell phone 412 759 9492 or email

#22705 From: "Bryan Schulz" <b.schulz@...>
Date: Sun Dec 20, 2009 8:25 pm
Subject: Re: c# problems help
bryan4772002
Offline Offline
Send Email Send Email
 
you posted this same message last week.
start from scratch or something cuz you're not figuring it out.
 
Bryan Schulz
----- Original Message -----
Sent: Wednesday, December 16, 2009 6:11 PM
Subject: [helpwithvb] c# problems help

 

hi.
well posted this question on programmers-town@yahoogroups.com
tried to look for the sample code examples on the net.
did find some.
but looks the same or similar.
but still just displaying my name.
could it be a jaws problem.
windows vista problem.
the c# compiler problem.
please visit this link to read this post.
cheers Marvin.

http://tech.groups.yahoo.com/group/Programmers-Town/message/12661


#22704 From: "nezardidol" <nezard@...>
Date: Sat Dec 19, 2009 4:41 pm
Subject: repeater control
nezardidol
Offline Offline
Send Email Send Email
 
I have data to display in a repeater control. When the data in a one of the
fields is a particular word I want to make it a link. Any other word in this
field should be displayed without a link. I have been trying to use an If
statement with no success.

Can someone help me with this?

Thanks,
Norine

#22703 From: "Marvin Hunkin" <startrekcafe@...>
Date: Thu Dec 17, 2009 12:11 am
Subject: c# problems help
neilmarvin
Offline Offline
Send Email Send Email
 
hi.
well posted this question on programmers-town@yahoogroups.com
tried to look for the sample code examples on the net.
did find some.
but looks the same or similar.
but still just displaying my name.
could it be a jaws problem.
windows vista problem.
the c# compiler problem.
please visit this link to read this post.
cheers Marvin.

http://tech.groups.yahoo.com/group/Programmers-Town/message/12661

#22702 From: Manual Camaro <macamaro2005@...>
Date: Fri Dec 18, 2009 9:21 pm
Subject: MP3
macamaro2005
Offline Offline
Send Email Send Email
 
THANK YOU so much to Tim Lewis. for all your information on MP3.

#22701 From: "Tim Lewis" <twlewis@...>
Date: Wed Dec 16, 2009 5:28 pm
Subject: RE: Mp3
twlewis64
Offline Offline
Send Email Send Email
 

The guts of an MP3 players is a flash drive.  I made the mistake of buying a flash drive while in China and had the same issue.  Windows never would recognize it.  After much research, I found that the drivers are installed by the manufacturer directly on to the device.  I don’t think that there is anything that you can do.

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Manual Camaro
Sent: Tuesday, December 15, 2009 4:37 PM
To: helpwithvb@yahoogroups.com
Subject: [helpwithvb] Mp3

 

 

Hi all. Can somebody help me on mp3. I purchase one from China (fake) I lost all info the only think is this, if I connect to computer only shows hourglass logo and that's it. I think I need driver, where can i get it?.

THANK YOU. Any help is appreciated.


#22700 From: "Timothy Rupp" <tim.rupp@...>
Date: Wed Dec 16, 2009 11:45 am
Subject: RE: MDI Form
timrupp804
Offline Offline
Send Email Send Email
 

http://msdn.microsoft.com/en-us/library/aa984347(VS.71).aspx

 

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Kishore Kumar
Sent: Wednesday, December 16, 2009 6:30 AM
To: Helpwithvb YahooGroups
Subject: [helpwithvb] MDI Form

 

 

How can i find the active child in a mdi form.

and how can i find all the childs on the mdi.





#22699 From: Kishore Kumar <gemini_kesa@...>
Date: Wed Dec 16, 2009 11:30 am
Subject: MDI Form
gemini_kesa
Offline Offline
Send Email Send Email
 
How can i find the active child in a mdi form.
and how can i find all the childs on the mdi.


The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.

Messages 22699 - 22728 of 22728   Newest  |  < Newer  |  Older >  |  Oldest
Advanced
Add to My Yahoo!      XML What's This?

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help