Question:
VB.net Pause in loop until input?
sadistic_impulses
2011-12-06 11:23:55 UTC
Here's my situation, I have two forms in Visual basic.net. and both of them play a part in this loop that's dedicated to filling the second form with data, but is triggered on the first form.

I have the following algorithm


For i = 0 to 3
*Update 4 items in the second form*

next i

Ok, so the loop is situated behind an object on the first form that acts as a trigger, but what I want to do is get the loop to stop untill I select an item from a radio button, and then click a "next loop" button on the other form.




So basically I want this;

*user clicks start on form A
For i = 0 to 3
*Update 4 items in form B*
*pause and wait for user to click Next button on Form B*
next i
Four answers:
?
2011-12-06 14:12:01 UTC
VB is an event driven language, you are not thinks interms of events but in terms of a proceedure driven language. In other words you are trying to force the use or a loop into a situation where the use of events (like a button clicked by a user) would work much better and will be in line with an event drive language like VB



instead of using a for next loop, use a button click event that responds to the user clicking on a form.





Since you want four differentbthings to happen you can code this same button to respond four different ways each time its clicked. As each button click is handled Vb will naturally pause and await for the user to click the button again for the next test





In a button click event handlers add the following



A static variable that will be used as a counter variable. A select case statement that will branch to the different test and an if statment that will handle the counter variable







Static count as integer



Select case count

Case 0

Do test 0



Case 1

Do test 1



....

Case 3

Do case 3



End case



Count = count + 1

If count > 3 then count = 0







You can still use a loop to fill of the form for a given test Just place your code where it saya do test x.

After thatbloop completes it drop out of the loop and completes it exits the select case updates the count and exits the button clock qnd will wait fornthe user to click the button qgain for the next test.
samofcalifornia
2011-12-06 12:26:41 UTC
I am not sure if you want all 4 items to be entered in the other form or if you want to show the other form 4 times. I will assume that you want to show the second form 4 times (once for each item).



Use ShowDial​og instead of Show. Then Windows will automatically pause. So the code will be something like:



Dim f As New Form2()

For i = 0 to 3

f.ShowDialog(Me)

' get the data

next i

f.Dispose()
AJ
2011-12-06 11:33:59 UTC
make the second form a dialog box.



But you do realize, that what you are asking is to update 4 items on form B, FOUR TIMES.



dim frmB as new FormB

if frmB.ShowDialog = DialogResult.OK then end if
larrauri
2016-11-19 04:44:43 UTC
here is yet in any different case of looking at Purgatory. An analogy which will help you cope with what we advise by applying Purgatory is the tip that the "fireplace" of Purgatory is easily the affection of God. certainly, actual understood, the "fireplace" of Purgatory, the "fireplace" of Hell, and the "fireplace" of Heaven (for the OT speaks of Heaven as a "fiery" place somewhat usually) is all, in certainty, an identical fireplace, that's the burning and unquenchable Love of Almighty God. And, looking on the disposition of a soul on the time of loss of life, while each thing else different than God is stripped remote from them, the soul will the two be stricken by applying this "fireplace" (i.e., Hell because of the fact the soul needs not something to do with God), or he would be purged of lingering sin by applying this "fireplace" (Purgatory), or he would be able to unite with the "fireplace" itself (Heaven), in view that the two the soul and the fireplace proportion a topic-unfastened Nature (2 Peter a million:4)--it somewhat is, the soul has already been converted right into a picture of Christ (a saint) previous to loss of life. So, easily relies upon on the soul's disposition. Or, look at it this way: If somebody is asleep in a gloomy room, and somebody without notice throws open the curtains to bare a fantastic, sunny day, and if the guy has had a solid evening's sleep, and is able to awaken, he would be able to open his eyes and greet the morning solar with out subject (i.e., Heaven). regardless of the incontrovertible fact that, if the guy is afflicted by a terrible dangle-over and has had little or no sleep in any respect, he will conceal his face under the blankets and choose not something to do with the solar (i.e., Hell). regardless of the incontrovertible fact that, if he's in basic terms somewhat hung-over, or nonetheless somewhat sleepy, he would be able to open his eyes somewhat—to tentatively look on the solar, as he struggles to acclimate to the morning solar (i.e., Purgatory). In essence, that's all Catholicism is asserting with regard to the Afterlife, while a Christian finally sees the staggering actuality, that's God. in the event that they think of approximately it, a Protestant would not have faith in any different case in any respect. God Bless Robin


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...