473,834 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2582
Is the process that is generating the random numbers just a loop?
While not paused
GenerateRandonN umber
Wend

Something like that?
If it is then try:
While not paused
GenerateRandonN umber
Application.DoE vents
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.DoE vents()
.....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
GenerateRandonN umber
Wend

Something like that?
If it is then try:
While not paused
GenerateRandonN umber
Application.DoE vents
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.DoE vents()
' ... 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.DoE vents
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
GenerateRandonN umber
Wend

Something like that?
If it is then try:
While not paused
GenerateRandonN umber
Application.DoE vents
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.DoE vents() 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 RandGenerationS tate
As Short {Start, Stop, Active, Pause, Resume}. Declare a private form level
variable of type RandGenerationS tate = RandGenerationS tate.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.St op
Dim grGraphics As (GraphicStuff)
Dim al_dblRanNums As New ArrayList

Sub ButtonArrayClic k() Handles ArrayButtonsCli cking

If focus is Start then
If rgsCurrentState = RandGenState.St op then
rgsCurrentState = RandGenState.St art
async call DoRandGeneratio n
Else
Show "Dummy! You can't do that!"
End If

If focus is Pause then
If rgsCurrentState = RandGenState.Ac tive then
rgsCurrentState = RandGenState.Pa use
'The async DoRandGeneratio n will pause it
Else
Show "Idiot! Its not even running!"
End If
End If

If focus is Resume then
If rgsCurrentState = RandGenState.Pa use then
rgsCurrentState = RandGenState.Re sume
async call DoRandGeneratio n
Else
Show "Nimrod! You can't resume if its not paused"
End If
End If

If focus is Stop then
If rgsCurrentState = RandGenState.Ac tive Or _
rgsCurrentState = RandGenState.Pa use then
If rgsCurrentState = RandGenState.Ac tive then
rgsCurrentState = RandGenState.St op
'The async DoRandGeneratio n will stop it
Else
rgsCurrentState = RandGenState.St op
'The async DoRandGeneratio n is not running so we manually
clear
call async ClearRandGenera tion
End If
Else
Show "Loser! Next time use a dice and crayon!"
End If

Show "Abort, Retry, Ingore"

End Sub

Sub DoRandGeneratio n()

Dim lngIndex as Long = 0

'Setup for resume
If rgsCurrentState = RandGenState.Re sume then
lngIndex = al_dblRanNums.C ount
rgsCurrentState = RandGenState.St art
End If

'Check starting
If rgsCurrentState = RandGenState.St art then
rgsCurrentState = RandGenState.Ac tive
End

Do While rgsCurrentState = RandGenState.Ac tive
<Do your stuff>
Loop

Select Case rgsCurrentState
Case RandGenState.Pa use
<pause clean up>
Case RandGenState.St op
call ClearRandGenera tion
End Select

End Sub

Sub Clear RandGeneration
grGraphics.Fina lPaint
al_dblRanNums.C lear
End Sub

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

--Robby

MCSD VB6 (currently updating)


"MgGuigg" <Mg*****@discus sions.microsoft .com> wrote in message
news:1F******** *************** ***********@mic rosoft.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.DoE vents()
.....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.DoE vents() 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 DoRandGeneratio n and ClearRandGenera tion 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
DoRandGeneratio n 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.DoE vents() 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 RandGenerationS tate
As Short {Start, Stop, Active, Pause, Resume}. Declare a private form level
variable of type RandGenerationS tate = RandGenerationS tate.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.St op
Dim grGraphics As (GraphicStuff)
Dim al_dblRanNums As New ArrayList

Sub ButtonArrayClic k() Handles ArrayButtonsCli cking

If focus is Start then
If rgsCurrentState = RandGenState.St op then
rgsCurrentState = RandGenState.St art
async call DoRandGeneratio n
Else
Show "Dummy! You can't do that!"
End If

If focus is Pause then
If rgsCurrentState = RandGenState.Ac tive then
rgsCurrentState = RandGenState.Pa use
'The async DoRandGeneratio n will pause it
Else
Show "Idiot! Its not even running!"
End If
End If

If focus is Resume then
If rgsCurrentState = RandGenState.Pa use then
rgsCurrentState = RandGenState.Re sume
async call DoRandGeneratio n
Else
Show "Nimrod! You can't resume if its not paused"
End If
End If

If focus is Stop then
If rgsCurrentState = RandGenState.Ac tive Or _
rgsCurrentState = RandGenState.Pa use then
If rgsCurrentState = RandGenState.Ac tive then
rgsCurrentState = RandGenState.St op
'The async DoRandGeneratio n will stop it
Else
rgsCurrentState = RandGenState.St op
'The async DoRandGeneratio n is not running, manually clear
call async ClearRandGenera tion
End If
Else
Show "Loser! Next time use a dice and crayon!"
End If

Show "Abort, Retry, Ingore"

End Sub

Sub DoRandGeneratio n()

Dim lngIndex as Long = 0

'Setup for resume
If rgsCurrentState = RandGenState.Re sume then
lngIndex = al_dblRanNums.C ount
rgsCurrentState = RandGenState.St art
End If

'Check starting
If rgsCurrentState = RandGenState.St art then
rgsCurrentState = RandGenState.Ac tive
End

Do While rgsCurrentState = RandGenState.Ac tive
<Do your stuff>
Loop

Select Case rgsCurrentState
Case RandGenState.Pa use
<pause clean up>
Case RandGenState.St op
call ClearRandGenera tion
End Select

End Sub

Sub ClearRandGenera tion
grGraphics.Fina lPaint
al_dblRanNums.C lear
End Sub

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

--Robby

MCSD VB6 (currently updating)


"MgGuigg" <Mg*****@discus sions.microsoft .com> wrote in message
news:1F******** *************** ***********@mic rosoft.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.DoE vents()
.....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.DoE vents()
' ... 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.DoE vents
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
GenerateRandonN umber
Wend

Something like that?
If it is then try:
While not paused
GenerateRandonN umber
Application.DoE vents
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...(easie r to show than to explain...)

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

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

TextBox6.Visibl e = 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...C heers.

"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.DoE vents()
' ... 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.DoE vents
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
GenerateRandonN umber
Wend

Something like that?
If it is then try:
While not paused
GenerateRandonN umber
Application.DoE vents
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
3994
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 script is running. Is this possible to do with a textbox? I've tried using the response.flush with a variable which kinda works but it displays as follows; 1000 2000 3000
6
5771
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 use of checkpoints (for simple recovery and Backup Log for full recovery). On several website people speak about full transaction log and the pace of growing can't keep up with the update. Therefore we want to create a script which flushes the...
41
10683
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 = String.Format("SELECT * FROM dbo.documents WHERE ") & query End Sub
2
1304
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 share, processes them and copies them to another location. Depending on the number of images this can take a long time. If I update the dll (assembly) in the /bin folder the process dies and the user is given a "Server Application Unavailable"...
9
3147
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 following function:
1
2177
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 2000 Server), we have a randomly timeout on the vbc.exe process while users are connected to the application... This error never occured on our other customers servers. Any idea ? Here is the error message :
13
5333
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 40 of them throw Concurrency violation errors in the update, and my GetAllColErrs function provides no output. In comparing the rows that throw errors with those that do not, I could find no pattern. It is obviously a bogus error, as the...
7
2656
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 the following variable: Public PrintTheSub as string and the following subs:
2
5720
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 javascript function that uses the ClientID of the dynamic controls to perform certain operations on the client-side. With each partial page post back, I dynamically recreate the javascript function using the ClientIDs of the newly added controls....
0
9799
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9332
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6957
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3981
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3083
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.