Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delay in calling a function 1

Status
Not open for further replies.

jimberger

Programmer
Jul 5, 2001
222
0
0
GB
Hello all,

I have a button on one form then when pressed it will change colour and then goto another form; so in my click function i have

normal_button.visible = false
coloured_button.visible = true
call newform.show

however, i want a second delay before calling the next function so people can say that the button has changed colour before going to the next screen. At the moment, when the button is pressed, it immedialey goes to the next form and you cant see that the button had changed colour.

Is they a way to do this in VB?]
thanks for your help
 
You could use the Sleep API

Put:

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

In a Module then, after changing the button color but before opening the next form, say:

Sleep 1000
 
You Could also use a timer to create a delay.

Sub Button_Click()
timer1.delay=1000
timer1.enabled=true
normal_button.visible = false
coloured_button.visible = true

end Sub

sub Timer1_Timer()
call newform.show
end sub

Thanx Dave Shaw!
 
Or, you could think about the process and decide that the whole concept was un-necessary.

Or -why bother?- If the point of the cmd button is to show the next form who cares what happens on the current form? Isn't it irrelevant?

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Though I do question the reasoning behind making a program lag just so that the user can see a button change color, there are times when a programmer will want to delay a given procedure (e.g., waiting 5 seconds before closing an application for a print job to complete).

The suggestions here are useful.

-----
The death of dogma is the birth of reason.
 
Use Button_MouseDown to change the color of the button and Button_MouseUp to open the form
The button will show button color change only while the user holds the button down and will instantly show the form when they release it.
Then a fast user doesnt have to wait for some arbitrary delay imposed by someone else but an unsure user definitely has confirmation that they have clicked on the correct button.
Also make all your command button in the app with the same name but a different index and you only need 2 subs with a select case to select and change all buttons.
This is also handy for changing the color of text boxes to yellow when they get and loose the focus.
 
Good ones.
The fact is that the utility of changing the color of a button just for signifying that the button has been clicked is, an opinion of mine, out of purpose. It is always difficult to think about everything in an application, I'll admit it. What will simplify the life of the user?

Just take one exemple: validing a name textbox. If you get through validating all caracters to see if the correspond to alphabetic group, you'll get a problemm with names that correspond to "O'neil", for instence. So you'll got to get farer to analysis of the problem(which isn,t really one). You'll get to check for " ' " and that leads to another problem: " - ". It will ends that the user will not be able to enter it proper name just because the application will have been made just too perfect.

Be carfull not to disapoint user when you want your program to be more suitable!
;-)

 
VB Command buttons have A DOWNICON property for this purpose.
Rather than change color, you can make the icon on the button animate when you click on it by using the sub command1_mouseup instead of the _click to open the form or do whatever the button does in the app.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top