求助:VB 程序调试出现堆栈空间溢出
Private Sub Form_Load()Dim Gam As Double, Gam1 As Double, Gam2 As Double, Gam4 As Double, Vin As Double
Dim X0 As Double, X2 As Double, R As Double, FN As Double, FOFX As Double, Z As Double
Gam = InputBox("请输入绝热指数", "输入绝热指数")
Vin = InputBox("请输入入口普朗特-迈耶角", "输入入口普朗特-迈耶角")
X2 = InputBox("请输入半径取值上限", "输入半径取值上限")
Const Conver = 0.0174532945
Const PI = 3.14159265
Const Increment = 0.1
Gam1 = (Gam + 1#) / 2#
Gam2 = (Gam - 1#) / 2#
Gam4 = Sqr((Gam + 1#) / (Gam - 1#))
X0 = Sqr((Gam - 1#) / (Gam + 1#))
Vin = Vin * Conver
FN = 1#
FOFX = F(Vin, FN)
Call Root(X0, X2, FOFX, FOFRS(Z), R)
End Sub
'//////启动程序设计//////
'//////启动程序设计//////
'//////启动程序设计//////
'//////启动程序设计//////
'//////求解R*的函数//////
'//////求解R*的函数//////
'//////求解R*的函数//////
'//////求解R*的函数//////
'定义函数Root,求解半径值R*
Public Function Root(X0 As Double, X2 As Double, FOFX As Double, FOUNC, X1)
Dim X As Double
Dim XX0 As Double
Dim XX2 As Double
Dim F0 As Double
Dim F2 As Double
Dim FX As Double
XX0 = X0
XX2 = X2
Call FOUNC(XX0)
F0 = FOUNC(XX0)
'Print "FO="; FO; ""
Call FOUNC(XX2)
F2 = FOUNC(XX2)
'Print "F2="; F2; ""
Do
X = (XX0 + XX2) / 2#
FX = FOUNC(X)
If FOFX > FX Then
XX2 = X
F2 = FX
Else
XX0 = X
FO = FX
End If
Loop Until Abs(XX0 - XX2) < 0.0000000001
X1 = X
' Print " 输出半径X1= "; X1; ""
Root = X1
End Function
'///定义FOFRS(X)函数,求函数F(R*)的值(方程(10b)),其中X即为所求半径
Public Function FOFRS(X As Double)
Dim Arg1 As Double
Dim Arg2 As Double
Arg1 = 2# * Gam2 / (X * X) - Gam
Arg2 = 2# * Gam1 * X * X - Gam
'If -1 <= Arg1 And Arg1 <= 1 And -1 <= Arg2 And Arg2 <= 1 Then
FOFRS = Gam4 * Asin(Arg1) + Asin(Arg2)
'End If
End Function
'////定义反正弦函数
Public Function Asin(X As Double)
Asin = Atn(X / Sqr(1# - X * X))
End Function
Public Function F(X As Double, Y As Double)
F(X, Y) = 2# * X - (PI / 2#) * (Gam4 - 1#) - 2# * (Y - 1#) * Increment
End Function
标红部分现实:堆栈空间溢出;
求高手指导,不甚感激!
[ 本帖最后由 huangzhenyu 于 2013-3-23 10:06 编辑 ]