Sub buttok
button34.Visible=true
Do Until butok = 1
DoEvents
[COLOR="Red"]Sleep(50)[/COLOR]
Loop
butok=0
button34.Visible=false
label76.Text=""
End Sub
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.
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.What other method is there to halt the program till a particular button is pressed, my heads puddled
Button34_Click sets butok to 1
buttok halts the program till button34 is clicked.
' 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
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).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.
You could set what I would refer to as a flag which if true allows play to continue.
Regards,
RandomCoder
do until flag = 1
doevents
loop
Sub buttok
button34.Visible=true
Do Until butok = 1
DoEvents
Sleep(50)
Loop
butok=0
button34.Visible=false
label76.Text=""
End Sub
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.
Sub enbuts
For a = 1 To 22
If box(a).used = 1 Then
Control("Button" & a).Enabled = true
End If
Next a
End Sub
Sub dibuts
For a = 1 To 22
If box(a).used = 1 Then
Control("Button" & a).Enabled = false
End If
Next a
End Sub
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.Question: Is there another other method , (not an endless loop), to halt the program till a particular button (or action) has taken place :sign0163:
I think that you have missed the point of my earlier reply.
I'm thinking of letting full paid registered members of basic4ppc have a full free evaluation copy of the game. Purely for beta testing whilst I am waiting for Endemol to reply to me. It would be a personal compiled version with the members name in the 'About' screen. That way If it crept it's way onto the net I'd know who leaked it.
I like that apoach to a "beta test user" control...
Nice thinking...
I'm thinking of letting full paid registered members
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?