(Urgent,Urgent,Urgent)A nasty problem(need MVP to answer)

(Urgent,Urgent,Urgent)A nasty problem(need MVP to answer)

Post by Einstei » Tue, 01 Jul 2003 13:14:38


Hello MVPs:

I got some code as follows:
=====================================================================
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim this As Long
Dim last As Long

Private Sub Command1_Click()
Static i
i = (i + 1) Mod 2
this = GetTickCount
Debug.Print "this:"; this
Debug.Print "this-last:"; this - last
Debug.Print "last-this:"; last - this

If (this - last) <= 200 Then End
If (this - last) > 200 Then
If i = 1 Then Timer1.Enabled = True
If i = 0 Then Timer1.Enabled = False
End If
last = this
==============================================
How can u explain this code for me,specially in why (this-last<=200)? ,when
u double click this commandbutton it'll end this form. Why?
 
 
 

(Urgent,Urgent,Urgent)A nasty problem(need MVP to answer)

Post by dolthar » Tue, 01 Jul 2003 14:33:03

Microsoft Says:

End Statement

Terminates execution immediately. Never required by itself but may be
placed anywhere in a procedure to end code execution, close files
opened with the Open statement and to clear variables.

I say:

maybe you were looking for "End Sub", that way you will terminate the
sub execution but not the whole program.

I've test your code and my best doubleclick rate is 111 tick
a way below you're 200 tickcount test

My average doubleclick rate is 170-180

Doltharz
NOT a MVP but... i hope it may help you



On Mon, 30 Jun 2003 12:14:38 +0800, "Einstein"




I'm not a GURU, an EXPERT or something like that.
I'm just a passionnate programmer.

Doltharz

 
 
 

(Urgent,Urgent,Urgent)A nasty problem(need MVP to answer)

Post by Klaus H. P » Tue, 01 Jul 2003 14:39:36

What do you mean? If "last" (which is the return from GetTickCount) is less
than or equal to 200, then the End statement is executed. Which is a very
bad idea.


--
____________________
Klaus H. Probst, MVP
http://www.yqcomputer.com/


Please post/reply to the newsgroup(s)
 
 
 

(Urgent,Urgent,Urgent)A nasty problem(need MVP to answer)

Post by dolthar » Tue, 01 Jul 2003 15:04:27

If you what my point

this code seems to have been done to prevents users with the
doubleclick mania to doubleclick on the button and then pretend
nothing happens or simply to avoid too fast re-execution.

I'm not a GURU, an EXPERT or something like that.
I'm just a passionnate programmer.
Doltharz

On Mon, 30 Jun 2003 12:14:38 +0800, "Einstein"
 
 
 

(Urgent,Urgent,Urgent)A nasty problem(need MVP to answer)

Post by dolthar » Tue, 01 Jul 2003 15:06:30

If you WANT my point...
sorry i'm not used to english...

Doltharz

On Mon, 30 Jun 2003 02:04:27 -0400, doltharz < XXXX@XXXXX.COM >





I'm not a GURU, an EXPERT or something like that.
I'm just a passionnate programmer.

Doltharz
 
 
 

(Urgent,Urgent,Urgent)A nasty problem(need MVP to answer)

Post by Einstei » Tue, 01 Jul 2003 16:02:23

Do u have any good idea?

"doltharz" < XXXX@XXXXX.COM > ????



,when
 
 
 

(Urgent,Urgent,Urgent)A nasty problem(need MVP to answer)

Post by Prodip Sah » Wed, 02 Jul 2003 22:42:04

Wrong group to post this question (work flow).



,when
 
 
 

(Urgent,Urgent,Urgent)A nasty problem(need MVP to answer)

Post by Sin » Thu, 03 Jul 2003 00:02:11

> Just replace the "End" by "End Sub"

That would be Exit Sub...

Alex.
 
 
 

(Urgent,Urgent,Urgent)A nasty problem(need MVP to answer)

Post by dolthar » Thu, 03 Jul 2003 00:26:19

Sorry...you're right... it's what i mean...
Placing End Sub at that place is totally impossible
(i feel stupid a little bit)

I'm not a GURU nor EXPERT or something like that
(you've got the proof).
I'm just a passionnate programmer.

Doltharz