Home > Software engineering >  VB program is run without response
VB program is run without response

Time:09-30

Below is my according to the flow chart to write a piece of code, but no response of the program, don't know where is wrong? I learn mechanical, programming ability is limited, also give more help please the great god, help me have a look at what's on the logical mistakes? Grateful!
Dim Dw0 As Double, dm0 As Double, Z0 As Double, Dw1 As Double, dm1 As Double, z1 As Double, t As Double, fc As Double
Dim Dwmin As Double, dmmin As Double, Zmin As Double, Dwmax As Double, dmmax As Double, Zmax As Double
Dim wj As Double, nj As Double, kd As Double, e1 As Double, e2 As Double, p2 As Double, p1 As Double, g As Double
Dim As Long, I str1 As String, str2 As String, str3 As String, SS As a Double, As Double f1 and f0 As Double
Dim FF0 As Double, FF1 As Double, tj1 As Double, tj2 As Double
Wj=CDbl (Text3. Text)
Nj=CDbl (Text2. Text)
Kd=CDbl (Text4. Text)
'calculating variable minimum
Dwmin=0.3 * (wj, nj)
Dmmin=0.5 * (wj + nj)
E1=Dwmin/dmmin
G=Round (e1, 2)
P1=(Atn (e1/Sqr (- e1 * e1 + 1))) * 180/3.1415926
Zmin=(180/2/p1) + 1
'a maximum of calculating variable
Dwmax=0.6 * (wj, nj)
Dmmax=0.515 * (wj + nj)
E2=Dwmin/dmmin
The p2=(Atn (e2/Sqr (e2 - e2 * + 1))) * 180/3.1415926
Zmax=(186/2/p2) + 1
'to the three variables initialization
Dw0=Dwmin
Dm0=dmmin
Z0=Zmax
'select load coefficient of the fc
Call openRs (" select [fc] from zhxs_fc where [bz]="& amp; Round (e1, 2))
Fc=rs. Fields (0)
Rs. Close
'Do
I=0
Str1=Grad_unit_1 (Dw0 dm0, Z0, fc, t)
Dw1=CDbl (Left (str1, InStrRev (str1, "%") - 1))
Dm1=Mid (str1 InStrRev (str1, "%") + 1, InStrRev (str1, "@") - InStrRev (str1, "%") - 1)
Z1=Right (str1, Len (str1) - InStrRev (str1, "@"))
SS=S (Dw1 dm1, z1, Dwmin, dmmin, Zmin, Dwmax, dmmax, Zmax)
'meet first determine whether convergence condition
If SS & gt; 0.0001 Then
Do
I=I + 1
Dw0=Dw1
Dm0=dm1
Z0=z1
T=0.4 * t
Str2=Grad_S (Dw0 dm0, Z0, Dwmin, dmmin, Zmin, Dwmax, dmmax, Zmax, t)
Dw1=CDbl (Left (str2, InStrRev (str2, "%") - 1))
Dm1=Mid (str2, InStrRev (str2, "%") + 1, InStrRev (str2, "@") - InStrRev (str2, "%") - 1)
Z1=Right (str2, Len (str2) - InStrRev (str2, "@"))
If I=1 Then
T=0.8
Str3=Grad_unit_1 (Dw0 dm0, Z0, fc, t)
Dw1=CDbl (Left (str3, InStrRev (str3, "%") - 1))
Dm1=Mid (str3, InStrRev (str3, "%") + 1, InStrRev (str3, "@") - InStrRev (str3, "%") - 1)
Z1=Right (str3, Len (str3) - InStrRev (str3, "@"))
SS=S (Dw1 dm1, z1, Dwmin, dmmin, Zmin, Dwmax, dmmax, Zmax)
The Else
SS=S (Dw1 dm1, z1, Dwmin, dmmin, Zmin, Dwmax, dmmax, Zmax)
End the If
Loop Until SS & lt;=0.0001
F0=f (Dw0, Z0, fc)
F1=f (Dw1, z1, fc)
The Else
F0=f (Dw0, Z0, fc)
F1=f (Dw1, z1, fc)
End the If
Tj1=f1 - f0
'meet the second convergence condition determine whether
If tj1 & gt;=10 ^ (8) Then
FF0=FF (Dw0, Z0, fc)
FF1=FF (Dw1, z1, fc)
If FF1 & lt; FF0 Then
Tj2=Sqr ((Dw1 - Dw0) ^ 2 + (dm1 - dm0) ^ 2 + (Z0 - z1) ^ 2)
If tj2 & lt; T Then=
T=(2 * t + tj2)/3
The Else
T=0.98 * t
End the If
The Else
T=0.5 * t
End the If
The Else
Text6. Text=Str (Dw1)
Text7. Text=Str (dm1)
Text8. Text=Str (z1)
Text9. Text=FF (Dw1, z1, fc)
End the If
Loop Until tj1 & lt; 10 ^ (8)
End Sub


Block diagram is as follows:

CodePudding user response:

What call procedure no response?
This sort of thing can only rely on themselves according to the flowchart to debug step by step, to see if the program's execution process and flow chart of consistent...

CodePudding user response:

Add: within the loop structure DoEvents

CodePudding user response:

reference 1st floor Topc008 response:
what call procedure no response?
This sort of thing can only rely on themselves according to the flowchart to debug step by step, to see if the program's execution process and flow chart of consistent...

I step through can run, because I am the main body of this procedure is a systemic circulation, the systemic circulation of the last operation, program is no response for a long time, so now I want to ask is, what's the problem is my program logic, the heart is close to my own ability I also look not to come out, so please help!

CodePudding user response:

Long cycle not over, the program will have no response,
If is infinite loop, or the input value is not correct, either code error, it should rely on yourself to find,
If it's just too long cycle time, such as # 2 says DoEvents, according to the following methods, interface counters always refresh,
 'add a Label on the form, by the way, assume that call lblLoopCount' 
Dim iLoopCount As Long 'a cycle counting variables'

Do
ILoopCount=iLoopCount + 1
LblLoopCount=iLoopCount
DoEvents' & lt; - add this few words'
...
Loop Until...
  • Related