473,416 Members | 1,503 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

updating variable from button during running process

Hello all, This is my first time posting a question to this forum, so here is
hoping I am following protocol. I am scraping the rust off my old Basic
programming skills, and have just recently upgraded to VB.NET, and I have a
lot of catching up to do. That being said, I have come a long way in a short
while, however, I am stumped at the moment. I have read through days of
posts, but have not been able to address my specific question, so here is
hoping I can find the answer on this site.

I have a running process that generates random numbers, and displays those
results on the forms page by means of both graphics and a textbox. My control
buttons on the form would allow the user to disrupt the process, as in either
a pause, or begin again mode. I have created a control array that places the
'AutoGenerate' button, the 'Pause' button, and the 'ReStart' button in the
same event handler. I expected that the program would recognize when the user
selected a button such as 'Pause while in the 'AutoGenerate' mode that would
allow me to use an 'If ....Then' statement to detect that a different control
had been selected and then react accodingly, as in 'pause' the program or
restart the program, depending on which button was selected, but instead,
when I click on anything after having selected the 'AutoGenerate' mode, while
in debug mode, the program just crashes, leaving me a large white area at the
bottom of the screen, and the need to 'Ctrl,Alt,Dlete' to get back to the
code window.

How do I get the program to recognize that a different control had been
selected during a running process, and act upon the controls intended
purpose, such as changing the value of a variable or the like? Any help would
be appreciated. Thankyou.
Nov 21 '05 #1
7 2557
Is the process that is generating the random numbers just a loop?
While not paused
GenerateRandonNumber
Wend

Something like that?
If it is then try:
While not paused
GenerateRandonNumber
Application.DoEvents
Wend

It could be that you are running in a loop that doesn't allow the program to
process other events.

Hope this helps.
Chris.
"MgGuigg" wrote:
Hello all, This is my first time posting a question to this forum, so here is
hoping I am following protocol. I am scraping the rust off my old Basic
programming skills, and have just recently upgraded to VB.NET, and I have a
lot of catching up to do. That being said, I have come a long way in a short
while, however, I am stumped at the moment. I have read through days of
posts, but have not been able to address my specific question, so here is
hoping I can find the answer on this site.

I have a running process that generates random numbers, and displays those
results on the forms page by means of both graphics and a textbox. My control
buttons on the form would allow the user to disrupt the process, as in either
a pause, or begin again mode. I have created a control array that places the
'AutoGenerate' button, the 'Pause' button, and the 'ReStart' button in the
same event handler. I expected that the program would recognize when the user
selected a button such as 'Pause while in the 'AutoGenerate' mode that would
allow me to use an 'If ....Then' statement to detect that a different control
had been selected and then react accodingly, as in 'pause' the program or
restart the program, depending on which button was selected, but instead,
when I click on anything after having selected the 'AutoGenerate' mode, while
in debug mode, the program just crashes, leaving me a large white area at the
bottom of the screen, and the need to 'Ctrl,Alt,Dlete' to get back to the
code window.

How do I get the program to recognize that a different control had been
selected during a running process, and act upon the controls intended
purpose, such as changing the value of a variable or the like? Any help would
be appreciated. Thankyou.

Nov 21 '05 #2
Thank you for your respone, I will try to clarify...
Button1.text = "ReStart"
Button8.text = "Continuous Draw"
Button10.text = "Pause"

The selection of button8 allows the execution of a continuous random number
to be generated and displayed. There is some graphics and some comparison
being done, but all this is working ok. After I select Button8 and after a
while decide to Pause or decide to ReStart by selecting button10 or Button1,
I would hope that the Continuous Draw loop would suspend, and the button
selected would execute.

Here is a sample of what I have...
While Button8.Focus = TRUE
'< I have added the App.DoEvent here on your suggestion..>
Application.DoEvents()
.....and here I create the random number etc....
End While

If Button10.focus = TRUE then
'... this is where I would put the pause event....
End If

If Button1.focus = TRUE then
' .... I am not sure how to reStart the module ....'
End If

However, it seems that any selection of button after Button8 has been
selected, is not being read into the program....I suspect that my ... If
focus...' statements are not the type I should be using to read whether a
button has been pressed...

Any further thoughts???


"Chris Podmore" wrote:
Is the process that is generating the random numbers just a loop?
While not paused
GenerateRandonNumber
Wend

Something like that?
If it is then try:
While not paused
GenerateRandonNumber
Application.DoEvents
Wend

It could be that you are running in a loop that doesn't allow the program to
process other events.

Hope this helps.
Chris.
"MgGuigg" wrote:
Hello all, This is my first time posting a question to this forum, so here is
hoping I am following protocol. I am scraping the rust off my old Basic
programming skills, and have just recently upgraded to VB.NET, and I have a
lot of catching up to do. That being said, I have come a long way in a short
while, however, I am stumped at the moment. I have read through days of
posts, but have not been able to address my specific question, so here is
hoping I can find the answer on this site.

I have a running process that generates random numbers, and displays those
results on the forms page by means of both graphics and a textbox. My control
buttons on the form would allow the user to disrupt the process, as in either
a pause, or begin again mode. I have created a control array that places the
'AutoGenerate' button, the 'Pause' button, and the 'ReStart' button in the
same event handler. I expected that the program would recognize when the user
selected a button such as 'Pause while in the 'AutoGenerate' mode that would
allow me to use an 'If ....Then' statement to detect that a different control
had been selected and then react accodingly, as in 'pause' the program or
restart the program, depending on which button was selected, but instead,
when I click on anything after having selected the 'AutoGenerate' mode, while
in debug mode, the program just crashes, leaving me a large white area at the
bottom of the screen, and the need to 'Ctrl,Alt,Dlete' to get back to the
code window.

How do I get the program to recognize that a different control had been
selected during a running process, and act upon the controls intended
purpose, such as changing the value of a variable or the like? Any help would
be appreciated. Thankyou.

Nov 21 '05 #3
Hi Chris, My last response to your post went somewhere, but I got an error
returned, so I will try this again...

First, thank you for your respone, I am sure that I will require that line
of code in my module...

Here is what I have...
Button1.text = " ReStart"
Button8.text = "Continuous Draw"
Button10.text = "Pause"

While Button8.Focus = True
'... I added your suggestion here....
Application.DoEvents()
' ... This is where I generate the random number etc., there is some
graphics
' ... and comparison going on, but all this works ok...
End While

If Button10.focus = TRUE then
' ... this is where I would place the pause event '
End If

If Button1.focus = TRUE then
' I am not sure how to get the module to restart....
End If

Once I select the Continuous Draw button with the mouse, the program
responds by generating random numbers and doing the comparisons and the
graphics, this part works ok, however, if after a bit I try to select
Button10 to Pause, or Button1 to ReStart the program initially just crashed,
but since I have added the line of code you suggested - Application.DoEvents
it appears that the new selected button is being selected (at least it
appears so because the button will show a depressed state while clicked on)
however, the program does not exit the Continuous Draw mode and just seems to
remain in the While loop...
Any suggestions??

"Chris Podmore" wrote:
Is the process that is generating the random numbers just a loop?
While not paused
GenerateRandonNumber
Wend

Something like that?
If it is then try:
While not paused
GenerateRandonNumber
Application.DoEvents
Wend

It could be that you are running in a loop that doesn't allow the program to
process other events.

Hope this helps.
Chris.
"MgGuigg" wrote:
Hello all, This is my first time posting a question to this forum, so here is
hoping I am following protocol. I am scraping the rust off my old Basic
programming skills, and have just recently upgraded to VB.NET, and I have a
lot of catching up to do. That being said, I have come a long way in a short
while, however, I am stumped at the moment. I have read through days of
posts, but have not been able to address my specific question, so here is
hoping I can find the answer on this site.

I have a running process that generates random numbers, and displays those
results on the forms page by means of both graphics and a textbox. My control
buttons on the form would allow the user to disrupt the process, as in either
a pause, or begin again mode. I have created a control array that places the
'AutoGenerate' button, the 'Pause' button, and the 'ReStart' button in the
same event handler. I expected that the program would recognize when the user
selected a button such as 'Pause while in the 'AutoGenerate' mode that would
allow me to use an 'If ....Then' statement to detect that a different control
had been selected and then react accodingly, as in 'pause' the program or
restart the program, depending on which button was selected, but instead,
when I click on anything after having selected the 'AutoGenerate' mode, while
in debug mode, the program just crashes, leaving me a large white area at the
bottom of the screen, and the need to 'Ctrl,Alt,Dlete' to get back to the
code window.

How do I get the program to recognize that a different control had been
selected during a running process, and act upon the controls intended
purpose, such as changing the value of a variable or the like? Any help would
be appreciated. Thankyou.

Nov 21 '05 #4
Hummm ...

This is your problem. The Button8.Focus While loop never exits. Why? Well
your application is running on one thread so an event has to complete so
that another can be processed. The Application.DoEvents() allows other
events to be generated BUT they can not be processed until the current event
from your Button8 click has completed. Therefore the While loop never gets
to process the new state of the focus and the other clicks are never
processed.

Solution? We really should not have heavy code in a click event like this.
Put your generation and graphic code in a form level private Sub and call
this from Button8 asyncronously. This way the event handeler is free to
process further events. Use the Delegate object to setup your asyncronous
calls.

Well then, how do you pause and resume? Declare your state data (the random
number and the graphics storage) as private form level variables. Create a
private form level state enumeration. For example: Enum RandGenerationState
As Short {Start, Stop, Active, Pause, Resume}. Declare a private form level
variable of type RandGenerationState = RandGenerationState.Stop. The Button
event handlers job is to check the state of this variable, update it and if
nessecary make the relevent asycronous call. The asycronous method in its
loop checks its state and conducts its self accordingly.

Here is some very rough pusedo-code using your design with the button focus.
I am using Hungarian notation for clarity of the pusedo-code. You should
use the .Net PascalCase and camelCase as per the .Net guidelines.
################################################## #

Enum RandGenState As Short {Start, Stop, Active, Pause, Resume}

Dim rgsCurrentState As RandGenState = RandGenState.Stop
Dim grGraphics As (GraphicStuff)
Dim al_dblRanNums As New ArrayList

Sub ButtonArrayClick() Handles ArrayButtonsClicking

If focus is Start then
If rgsCurrentState = RandGenState.Stop then
rgsCurrentState = RandGenState.Start
async call DoRandGeneration
Else
Show "Dummy! You can't do that!"
End If

If focus is Pause then
If rgsCurrentState = RandGenState.Active then
rgsCurrentState = RandGenState.Pause
'The async DoRandGeneration will pause it
Else
Show "Idiot! Its not even running!"
End If
End If

If focus is Resume then
If rgsCurrentState = RandGenState.Pause then
rgsCurrentState = RandGenState.Resume
async call DoRandGeneration
Else
Show "Nimrod! You can't resume if its not paused"
End If
End If

If focus is Stop then
If rgsCurrentState = RandGenState.Active Or _
rgsCurrentState = RandGenState.Pause then
If rgsCurrentState = RandGenState.Active then
rgsCurrentState = RandGenState.Stop
'The async DoRandGeneration will stop it
Else
rgsCurrentState = RandGenState.Stop
'The async DoRandGeneration is not running so we manually
clear
call async ClearRandGeneration
End If
Else
Show "Loser! Next time use a dice and crayon!"
End If

Show "Abort, Retry, Ingore"

End Sub

Sub DoRandGeneration()

Dim lngIndex as Long = 0

'Setup for resume
If rgsCurrentState = RandGenState.Resume then
lngIndex = al_dblRanNums.Count
rgsCurrentState = RandGenState.Start
End If

'Check starting
If rgsCurrentState = RandGenState.Start then
rgsCurrentState = RandGenState.Active
End

Do While rgsCurrentState = RandGenState.Active
<Do your stuff>
Loop

Select Case rgsCurrentState
Case RandGenState.Pause
<pause clean up>
Case RandGenState.Stop
call ClearRandGeneration
End Select

End Sub

Sub Clear RandGeneration
grGraphics.FinalPaint
al_dblRanNums.Clear
End Sub

###################################

--Robby

MCSD VB6 (currently updating)


"MgGuigg" <Mg*****@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
Thank you for your respone, I will try to clarify...
Button1.text = "ReStart"
Button8.text = "Continuous Draw"
Button10.text = "Pause"

The selection of button8 allows the execution of a continuous random
number
to be generated and displayed. There is some graphics and some comparison
being done, but all this is working ok. After I select Button8 and after a
while decide to Pause or decide to ReStart by selecting button10 or
Button1,
I would hope that the Continuous Draw loop would suspend, and the button
selected would execute.

Here is a sample of what I have...
While Button8.Focus = TRUE
'< I have added the App.DoEvent here on your suggestion..>
Application.DoEvents()
.....and here I create the random number etc....
End While

If Button10.focus = TRUE then
'... this is where I would put the pause event....
End If

If Button1.focus = TRUE then
' .... I am not sure how to reStart the module ....'
End If

However, it seems that any selection of button after Button8 has been
selected, is not being read into the program....I suspect that my ... If
focus...' statements are not the type I should be using to read whether a
button has been pressed...

Any further thoughts???

..
Nov 21 '05 #5

One thing I did not clarify completely. The Application.DoEvents() does not
execute your code in this case because all your button events have the same
handler. The other events can be processed because their handlers are not
active. Your global click event is active during the DoEvents so the new
click events are queued to be processed once the current click event
completes. However, the current click event completing is conditional on
the current handler being processed. Therefore your While loop never exits.
You would not have this problem if you used a different handler for each
button click event. Then you could do your generation syncronously. You
would still need to have a DoRandGeneration and ClearRandGeneration Sub
since some of the other event handlers need to call it. Finally you would
definately still need the RandGenState enumeration for state management.
For this design simply move each If stament from the global click handler to
each of there own handelers and place a do events inside the
DoRandGeneration Do While loop at the end.

--Robby
#### First post below ####

"Hummm ...

This is your problem. The Button8.Focus While loop never exits. Why? Well
your application is running on one thread so an event has to complete so
that another can be processed. The Application.DoEvents() allows other
events to be generated BUT they can not be processed until the current event
from your Button8 click has completed. Therefore the While loop never gets
to process the new state of the focus and the other clicks are never
processed.

Solution? We really should not have heavy code in a click event like this.
Put your generation and graphic code in a form level private Sub and call
this from Button8 asyncronously. This way the event handeler is free to
process further events. Use the Delegate object to setup your asyncronous
calls.

Well then, how do you pause and resume? Declare your state data (the random
number and the graphics storage) as private form level variables. Create a
private form level state enumeration. For example: Enum RandGenerationState
As Short {Start, Stop, Active, Pause, Resume}. Declare a private form level
variable of type RandGenerationState = RandGenerationState.Stop. The Button
event handlers job is to check the state of this variable, update it and if
nessecary make the relevent asycronous call. The asycronous method in its
loop checks its state and conducts its self accordingly.

Here is some very rough pusedo-code using your design with the button focus.
I am using Hungarian notation for clarity of the pusedo-code. You should
use the .Net PascalCase and camelCase as per the .Net guidelines.
################################################## #

Enum RandGenState As Short {Start, Stop, Active, Pause, Resume}

Dim rgsCurrentState As RandGenState = RandGenState.Stop
Dim grGraphics As (GraphicStuff)
Dim al_dblRanNums As New ArrayList

Sub ButtonArrayClick() Handles ArrayButtonsClicking

If focus is Start then
If rgsCurrentState = RandGenState.Stop then
rgsCurrentState = RandGenState.Start
async call DoRandGeneration
Else
Show "Dummy! You can't do that!"
End If

If focus is Pause then
If rgsCurrentState = RandGenState.Active then
rgsCurrentState = RandGenState.Pause
'The async DoRandGeneration will pause it
Else
Show "Idiot! Its not even running!"
End If
End If

If focus is Resume then
If rgsCurrentState = RandGenState.Pause then
rgsCurrentState = RandGenState.Resume
async call DoRandGeneration
Else
Show "Nimrod! You can't resume if its not paused"
End If
End If

If focus is Stop then
If rgsCurrentState = RandGenState.Active Or _
rgsCurrentState = RandGenState.Pause then
If rgsCurrentState = RandGenState.Active then
rgsCurrentState = RandGenState.Stop
'The async DoRandGeneration will stop it
Else
rgsCurrentState = RandGenState.Stop
'The async DoRandGeneration is not running, manually clear
call async ClearRandGeneration
End If
Else
Show "Loser! Next time use a dice and crayon!"
End If

Show "Abort, Retry, Ingore"

End Sub

Sub DoRandGeneration()

Dim lngIndex as Long = 0

'Setup for resume
If rgsCurrentState = RandGenState.Resume then
lngIndex = al_dblRanNums.Count
rgsCurrentState = RandGenState.Start
End If

'Check starting
If rgsCurrentState = RandGenState.Start then
rgsCurrentState = RandGenState.Active
End

Do While rgsCurrentState = RandGenState.Active
<Do your stuff>
Loop

Select Case rgsCurrentState
Case RandGenState.Pause
<pause clean up>
Case RandGenState.Stop
call ClearRandGeneration
End Select

End Sub

Sub ClearRandGeneration
grGraphics.FinalPaint
al_dblRanNums.Clear
End Sub

###################################

--Robby

MCSD VB6 (currently updating)


"MgGuigg" <Mg*****@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
Thank you for your respone, I will try to clarify...
Button1.text = "ReStart"
Button8.text = "Continuous Draw"
Button10.text = "Pause"

The selection of button8 allows the execution of a continuous random
number
to be generated and displayed. There is some graphics and some comparison
being done, but all this is working ok. After I select Button8 and after a
while decide to Pause or decide to ReStart by selecting button10 or
Button1,
I would hope that the Continuous Draw loop would suspend, and the button
selected would execute.

Here is a sample of what I have...
While Button8.Focus = TRUE
'< I have added the App.DoEvent here on your suggestion..>
Application.DoEvents()
.....and here I create the random number etc....
End While

If Button10.focus = TRUE then
'... this is where I would put the pause event....
End If

If Button1.focus = TRUE then
' .... I am not sure how to reStart the module ....'
End If

However, it seems that any selection of button after Button8 has been
selected, is not being read into the program....I suspect that my ... If
focus...' statements are not the type I should be using to read whether a
button has been pressed...

Any further thoughts???

..

Nov 21 '05 #6
I wouldn't use the Focus of a button to test if it's been pressed. It looks
like you are in a loop that never exits. Have a look at the reply from Robby.
If you are still stuck post and I'll try and help some more.

Chris.

"MgGuigg" wrote:
Hi Chris, My last response to your post went somewhere, but I got an error
returned, so I will try this again...

First, thank you for your respone, I am sure that I will require that line
of code in my module...

Here is what I have...
Button1.text = " ReStart"
Button8.text = "Continuous Draw"
Button10.text = "Pause"

While Button8.Focus = True
'... I added your suggestion here....
Application.DoEvents()
' ... This is where I generate the random number etc., there is some
graphics
' ... and comparison going on, but all this works ok...
End While

If Button10.focus = TRUE then
' ... this is where I would place the pause event '
End If

If Button1.focus = TRUE then
' I am not sure how to get the module to restart....
End If

Once I select the Continuous Draw button with the mouse, the program
responds by generating random numbers and doing the comparisons and the
graphics, this part works ok, however, if after a bit I try to select
Button10 to Pause, or Button1 to ReStart the program initially just crashed,
but since I have added the line of code you suggested - Application.DoEvents
it appears that the new selected button is being selected (at least it
appears so because the button will show a depressed state while clicked on)
however, the program does not exit the Continuous Draw mode and just seems to
remain in the While loop...
Any suggestions??

"Chris Podmore" wrote:
Is the process that is generating the random numbers just a loop?
While not paused
GenerateRandonNumber
Wend

Something like that?
If it is then try:
While not paused
GenerateRandonNumber
Application.DoEvents
Wend

It could be that you are running in a loop that doesn't allow the program to
process other events.

Hope this helps.
Chris.
"MgGuigg" wrote:
Hello all, This is my first time posting a question to this forum, so here is
hoping I am following protocol. I am scraping the rust off my old Basic
programming skills, and have just recently upgraded to VB.NET, and I have a
lot of catching up to do. That being said, I have come a long way in a short
while, however, I am stumped at the moment. I have read through days of
posts, but have not been able to address my specific question, so here is
hoping I can find the answer on this site.

I have a running process that generates random numbers, and displays those
results on the forms page by means of both graphics and a textbox. My control
buttons on the form would allow the user to disrupt the process, as in either
a pause, or begin again mode. I have created a control array that places the
'AutoGenerate' button, the 'Pause' button, and the 'ReStart' button in the
same event handler. I expected that the program would recognize when the user
selected a button such as 'Pause while in the 'AutoGenerate' mode that would
allow me to use an 'If ....Then' statement to detect that a different control
had been selected and then react accodingly, as in 'pause' the program or
restart the program, depending on which button was selected, but instead,
when I click on anything after having selected the 'AutoGenerate' mode, while
in debug mode, the program just crashes, leaving me a large white area at the
bottom of the screen, and the need to 'Ctrl,Alt,Dlete' to get back to the
code window.

How do I get the program to recognize that a different control had been
selected during a running process, and act upon the controls intended
purpose, such as changing the value of a variable or the like? Any help would
be appreciated. Thankyou.

Nov 21 '05 #7
Hi again,
First let me state that this reply is intended for both Rob and Chris, but
in the interest of no duplication, I am responding to the last entry on this
thread. I wish once again to thank both Rob and Chris for their time and
expertise. I mean, where would these boards be without these types of people.

I have read with great interest Rob's reply, and I will be looking alot
closer at his suggested method. I will be dissecting his response, and taking
it a step at a time, so please do not expect that I will have the re-written
code tested anytime soon.I have taken Chris' invitation to re-post as I
progress, and I can assure you that it will be both educational and fun.
Thanks Chris. I am directing every available moment to learning,
understanding, and working with VB.NET. (to the chagrin of my wife and
family...) I expect to take delivery today of a recently purchased 'Visual
Basic.Net BlackBook". I do not expect the book to all of a sudden make me an
efficient programmer, but I do expect that it will go a long way toward my
learning the required syntax etc. I would also mention that I have a deep
background in automation and have been programming PLC's and the like for
many years. I have dabbled in Python, worked a little with 'C Plus, Linux and
several other similar projects, however, I have decided to go with VB.Net,
and give it my all.

In the interest of learning VB.Net, I am using one of my old learning tools,
a favorite program that I write with any new language I undertake to learn.
This particular program is a colorful and robust version of a lotto draw type
program. I use this because it permits me to incorporate many of the
languages' features.

I have been experimenting with several approaches to my delima, the last
being a For..Next loop with the variable being set by the value expressed in
the click of the button...(easier to show than to explain...)

For z = butt To 150
Application.DoEvents()
butn = CType(sender, Button)

' ... the text box6 is so I can see what is taking place for debugging....

TextBox6.Visible = True
TextBox6.Text = " Z = " & z & " butt " & butt

butn = CType(sender, Button)

If butn.Text Is "END" Then
butt = 150
TextBox6.Text = " END BUTTON" & " Z = " & z & " butt " & butt

ElseIf butn.Text Is "Continuous Draw" Then
butt = 0
TextBox6.Text = " Continuous Draw Button" & " Z = " & z & "
butt " & butt
ElseIf butn.Text Is "PAUSE" Then
butt = 125
TextBox6.Text = " Pause Button" & " Z = " & z & " butt " &
butt
End If

z = butt
TextBox6.Text = " Z = " & z & " & " butt " & butt

' ... the following code would be the randon gen and the graphics ....
Next Z
' ... etc, etc,etc....
_____________________________

The above with the help of the textbox shows me 2 things, 1 - the button is
being recognized, as the value of Z will show the value designated by the
selected button, and 2 - I am still caught in a loop situation as the value
of Z returns to either a begin count value from 'zero' or flashes back to
continue counting from whatever value it was at prior to me clicking a
button. The idea was that Z would take on the new value, and as with the END
value, it would be set to 150, and the For..Next loop would end. However, as
I mentioned, the textbox shows that the value changes to the button value,
then quickly changes back as previously stated.

I expect that I will need to employ the concept that Rob has pointed out.
This should take me out of this loop situation and allow for the updates as
required.

I will get back to code crunching, and will respond to this thread again as
soon as I have made further progress. That could be anywhere from a few hours
(not likely) to a few days. Thanks again fellas, and here is to
programming...Cheers.

"Chris Podmore" wrote:
I wouldn't use the Focus of a button to test if it's been pressed. It looks
like you are in a loop that never exits. Have a look at the reply from Robby.
If you are still stuck post and I'll try and help some more.

Chris.

"MgGuigg" wrote:
Hi Chris, My last response to your post went somewhere, but I got an error
returned, so I will try this again...

First, thank you for your respone, I am sure that I will require that line
of code in my module...

Here is what I have...
Button1.text = " ReStart"
Button8.text = "Continuous Draw"
Button10.text = "Pause"

While Button8.Focus = True
'... I added your suggestion here....
Application.DoEvents()
' ... This is where I generate the random number etc., there is some
graphics
' ... and comparison going on, but all this works ok...
End While

If Button10.focus = TRUE then
' ... this is where I would place the pause event '
End If

If Button1.focus = TRUE then
' I am not sure how to get the module to restart....
End If

Once I select the Continuous Draw button with the mouse, the program
responds by generating random numbers and doing the comparisons and the
graphics, this part works ok, however, if after a bit I try to select
Button10 to Pause, or Button1 to ReStart the program initially just crashed,
but since I have added the line of code you suggested - Application.DoEvents
it appears that the new selected button is being selected (at least it
appears so because the button will show a depressed state while clicked on)
however, the program does not exit the Continuous Draw mode and just seems to
remain in the While loop...
Any suggestions??

"Chris Podmore" wrote:
Is the process that is generating the random numbers just a loop?
While not paused
GenerateRandonNumber
Wend

Something like that?
If it is then try:
While not paused
GenerateRandonNumber
Application.DoEvents
Wend

It could be that you are running in a loop that doesn't allow the program to
process other events.

Hope this helps.
Chris.
"MgGuigg" wrote:

> Hello all, This is my first time posting a question to this forum, so here is
> hoping I am following protocol. I am scraping the rust off my old Basic
> programming skills, and have just recently upgraded to VB.NET, and I have a
> lot of catching up to do. That being said, I have come a long way in a short
> while, however, I am stumped at the moment. I have read through days of
> posts, but have not been able to address my specific question, so here is
> hoping I can find the answer on this site.
>
> I have a running process that generates random numbers, and displays those
> results on the forms page by means of both graphics and a textbox. My control
> buttons on the form would allow the user to disrupt the process, as in either
> a pause, or begin again mode. I have created a control array that places the
> 'AutoGenerate' button, the 'Pause' button, and the 'ReStart' button in the
> same event handler. I expected that the program would recognize when the user
> selected a button such as 'Pause while in the 'AutoGenerate' mode that would
> allow me to use an 'If ....Then' statement to detect that a different control
> had been selected and then react accodingly, as in 'pause' the program or
> restart the program, depending on which button was selected, but instead,
> when I click on anything after having selected the 'AutoGenerate' mode, while
> in debug mode, the program just crashes, leaving me a large white area at the
> bottom of the screen, and the need to 'Ctrl,Alt,Dlete' to get back to the
> code window.
>
> How do I get the program to recognize that a different control had been
> selected during a running process, and act upon the controls intended
> purpose, such as changing the value of a variable or the like? Any help would
> be appreciated. Thankyou.

Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: rob | last post by:
Hi All, I have an asp script which updates upto 300000 records each time it is run. I would like to have a textbox which says records progressed : then in increments of 100 or 1000 whilst the...
6
by: Hennie de Nooijer | last post by:
Hi, Currently we're a building a metadatadriven datawarehouse in SQL Server 2000. We're investigating the possibility of the updating tables with enormeous number of updates and insert and the...
41
by: Miguel Dias Moura | last post by:
Hello, I am working on an ASP.NET / VB page and I created a variable "query": Sub Page_Load(sender As Object, e As System.EventArgs) Dim query as String = String.Empty ... query =...
2
by: wsMarkM | last post by:
I have a web app running on Windows 2000 with the home directory pointed to a network share on a file server. We have a long running process which copies jpg images from user's folders on a network...
9
by: Shapper | last post by:
Hello, I am declaring a variable in my aspx.vb code as follows: Public Class catalogue Public productid As String Private Sub Page_Load ... I have an image button where I call the...
1
by: Vavane | last post by:
When we update some files of our ASP.NET application on our customers servers, the vbc.exe process compiles these files "on the fly" at the first call. Right. For one server (running Windows...
13
by: mfreeman | last post by:
The minimal code (VB.NET 2003) needed to show this problem is shown below. All I do is loop through the records in the table and update them without making any changes. Out of 600 records, about...
7
by: ILCSP | last post by:
Hi, I'm using VB.Net (2003) and I have a question. Does anyone knows how to call a procedure using a variable? The variable will be equal to the name of the procedure. for example, if I have...
2
by: =?Utf-8?B?TUNN?= | last post by:
I have an asp.net page that contains an update panel. Within the update panel, controls get added dynamically. During partial page post backs the controls within the panel will change. I have a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.