求VB挂轮比代码
(51/55)*(83/88)=.874586776859504Dim a As Long, b As Long, c As Long, d As Long
Dim m As Double, n As Double
Dim k As Double
Dim a1 As Long, b1 As Long, c1 As Long, d1 As Long
Dim m1 As Double
k = 1
For a = 30 To 100
For b = 30 To 100
For c = 30 To 100
For d = 30 To 100
m = (a / b) * (c / d)
n = Abs(m - 0.8745865231)
If n < k Then
k = n
a1 = a
b1 = b
c1 = c
d1 = d
m1 = m
End If
Next d
Next c
Next b
Next a
Print "("; a1; "/"; b1; ")*("; c1; "/"; d1; ")="; m1
Debug.Print "(" & a1 & "/" & b1 & ")*(" & c1 & "/" & d1 & ")=" & m1
这个代码,我是在窗体有个text1.text,然后在text。text中输入实数,一般是小数点后七位,然后然后输出挂轮比,要求误差小于0.0002.这个程序不运行,大侠,看看应该怎么写,谢谢!