How many processes do you have running on your laptop for it to go turbo fan mode?
Are you sure about spyware?
The DoEvents enables your device to "pay attention" to others processes instead of "locking" to you app...so why Sleep?
Have you tried the code in a device?
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)
My Posts helped you? Consider Buying me a Porto Glass!
I would expect this as you are effectively running an endless loop and so using 100% of the CPU, it's getting warm and the fans are quite correctly coming on. Both of these waste battery energy. There will also be the same problem on the device
If you are having to do this then I am afraid that your program structure is not good. You really should be exitting Sub buttok and using whatever event triggers the variable butok to be set to 1 to take the next step.
I would expect this as you are effectively running an endless loop and so using 100% of the CPU, it's getting warm and the fans are quite correctly coming on. Both of these waste battery energy. There will also be the same problem on the device
That's what I thought.
Quote:
If you are having to do this then I am afraid that your program structure is not good. You really should be exitting Sub buttok and using whatever event triggers the variable butok to be set to 1 to take the next step.
Button34_Click sets butok to 1
buttok halts the program till button34 is clicked.
What other method is there to halt the program till a particular button is pressed, my heads puddled
__________________
.
.
. Don't ask, I'm fine, honest. !!
.
.
. Just a little crazy at times
O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80
What other method is there to halt the program till a particular button is pressed, my heads puddled
To effectively and efficiently code in Windows requires you to use event-based programming. In such programming you don't need to "halt" the program, you respond to an event occuring by running some code and then exiting from the Sub that the event invoked. Your code is then automatically "halted" by the Operating System until another event occurs for which you have written an event handler Sub.
Quote:
Button34_Click sets butok to 1
buttok halts the program till button34 is clicked.
I am not entirely clear what you want but how about the following?
Code:
' invoked by some event somewhere 'make Button34 visible and exit so waiting for another event Sub buttok button34.Visible=true End Sub
' Button34 clicked so hide it Sub Button34_Click button34.Visible=false label76.Text="" butok = 1 ' do anything else needed here End Sub
22 buttons (right side)
When an offer is made, 'Yes' and 'No' buttons are made visible at the bottom of the playing area.
It's instead of using a MsgBox which obscures the playing area but used to be my halt and return the values I needed.
Come on, this is version 99 by now. It needed a little player friendly bits added
If I don't disable all of the unused 22 buttons and wait for a 'Yes' or 'No' button_click, the user can still click any of the available 22 buttons, thus, ruining the game.
Once a 'Yes' button has been clicked, (offer taken), an 'OK' button (34) is displayed at the bottom instead, and the value the offer would have been. Again, if I don't wait for the, 'OK' click 'and' disable the other buttons until i've had the button34_click the user can still click the unused 22 buttons and spoil the game.
You could set what I would refer to as a flag which if true allows play to continue.
When either the 'yes', 'no' or 'OK' buttons are made visible the flag is made false. Following one of the buttons being clicked the flag is made true again if play is allowed to continue. Presumably each 'box' has its own click event which would first check if the flag was true else exit the sub.
That's how I would approach the problem anyway.
Regards,
RandomCoder
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
If I don't disable all of the unused 22 buttons and wait for a 'Yes' or 'No' button_click, the user can still click any of the available 22 buttons, thus, ruining the game.
I'm glad you spotted this for yourself. I had thought of mentioning this in my previous post but decided not to to keep it short(ish).
One downside of event-based programming is that you can't predict what events a user may cause so you have to be prepared for anything to happen. This can mean a lot of enabling or disabling or hiding controls, or may mean a lot of conditional testing within event Subs to see if an event should be ignored or not. As ever experience (and occasional (or frequent!) failure) are the best teachers to efficient program design together with (maybe) a bit of help from the elders of the tribe. I can count on over 42 years of coding and I'm still learning (more slowly each year regrettably as the faculties dim!)
Off for a drink or two myself 'cos there's bog all on the telly tonight (maybe that's what's doing in the faculties (the drink not the telly - but maybe ...)).
You could set what I would refer to as a flag which if true allows play to continue.
Regards,
RandomCoder
You mean like
Code:
dountil flag = 1 doevents loop
Code:
Sub buttok button34.Visible=true DoUntil butok = 1 DoEvents Sleep(50) Loop butok=0 button34.Visible=false label76.Text="" End Sub
Quote:
When either the 'yes', 'no' or 'OK' buttons are made visible the flag is made false. Following one of the buttons being clicked the flag is made true again if play is allowed to continue. Presumably each 'box' has its own click event which would first check if the flag was true else exit the sub.
The subs to enable/disable the unused 22 buttons is already in place.
Code:
Sub enbuts For a = 1To22 If box(a).used = 1Then Control("Button" & a).Enabled = true EndIf Next a End Sub
Sub dibuts For a = 1To22 If box(a).used = 1Then Control("Button" & a).Enabled = false EndIf Next a End Sub
Question: Is there another other method , (not an endless loop), to halt the program till a particular button (or action) has taken place
__________________
.
.
. Don't ask, I'm fine, honest. !!
.
.
. Just a little crazy at times
O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80
Question: Is there another other method , (not an endless loop), to halt the program till a particular button (or action) has taken place
I think that you have missed the point of my earlier reply. There is no need to ever halt your program yourself, it is halted automatically when you have finished processing an event until the next event occurs. Just let the event Sub exit and your program is halted. When the button you are waiting for is pressed then its' event sub will be called and you can do what is necessary then.
A problem that you might have is that other buttons may be pressed or other events occur that that you might want to ignore. You have to allow for this by either disabling other controls or including appropriate code in their event procedures.