Home > Software engineering >  VB6 for help, a great god to help in the do while suspended
VB6 for help, a great god to help in the do while suspended

Time:09-25

I need to write a complex iterative computation program, the n + 1 times with the results of the NTH calculation error is less than the given value of 0.00000000000000001, involving multiple sets of variables in the program, operation time is longer, want to design a pause button, want to pause when they click, and the process variables, at the same time also can restore program continues to run,
The first thing that went through my mind was the timer control, it's a pity that we had a few days are not successful, hope the great god to help

Or there are other ways (without the timer) can also, but say you can't multithreaded vb

 Sub yunsuan () 'main program 
For I=1 to 100
For j=1 to 100
The Do While Abs (a (I) - b (I)) & lt; 0.00000000001
B (I)=a (I)
A (I)=complex operations' n + 1 times with the NTH iterative calculation error is less than the given value
DoEvents
'judgment, the timer will suspend the program here, but how to contact Command1_Click
Loop
Next
Next
End Sub
Thank cbm666 great spirit of the program, I do not know how to associate yunsuan
Private Sub Form_Load ()
Command1. Caption="beginning"
Timer1. Interval=100
Timer1. Enabled=False
End Sub

Private Sub Command1_Click ()
Timer1. Enabled=Not Timer1. Enabled
The Select Case Command1. Caption
The Case Is="pause"
Timer1. Enabled=False
Command1. Caption="continued"
Call MySleep (10)
The Case Is="continued"
Timer1. Enabled=True
Command1. Caption="pause"
ForceStop=True
In Case the Else
Timer1. Enabled=True
Command1. Caption="pause"
End the Select
End Sub

Private Sub Timer1_Timer ()
I=I + 1
End Sub

Sub MySleep (Delaytm&)
Command1. Caption="continued"
ForceStop=False
Starttm=Timer
Do
DoEvents
If ForceStop Then Exit the Do
Loop Until the Timer - Starttm & gt;=Delaytm
Command1. Caption="beginning"
Command1_Click
End Sub

There is also the question of a weak-minded
I want to in the process of the program is running, in the form like Excel spreadsheet to real-time refresh my array values, suspended after can manually changing data

What kind of control is better
The number of columns, rows, according to program the array size automatic judgment, this is bad to solve it doesn't matter, I can use a text set to, is to some

CodePudding user response:

Try:

Private Sub Command1_Click ()
Bpause=not bpause
End sub
.
'at the back of the following add
'judgment, the timer will suspend the program here, but how to contact Command1_Click
The do while bpause
Doevents
Loop
.

CodePudding user response:

Thank you, I'll give it a try, it is estimated that even before the do while using doevents, release first, don't order button

CodePudding user response:

I know how
All calls into the timer, and can realize the suspension, the verification code "" "" "" "" ""

CodePudding user response:

I have achieved, as the upstairs said, all in a single call, using the timer implementation

CodePudding user response:

 Dim BO As Boolean 
Dim X As Long

Private Sub DoNext () 'public process cycle
I=X 'assignment here circulation of the initial value
Do
I=I + 1
If Not BO Then
Text1.=I 'Text Text box shows the circulation situation, I the change of the value of the
DoEvents
The Else
X=I
The Exit Do
End the If
'in the write cycle to perform the function of the code
Loop While I & lt; 500000 'set to cycle the number of times the value of the modified 500000 can
End Sub

Private Sub Command1_Click '() button control cycle pause and start
BO=Not BO changes DO the value of the object
The DoNext
End Sub

Private Sub Form_Load ()
BO BO=True 'object initial
X=0
End Sub

Have been debugging without a problem,
  • Related