# 数据溢出,怎么办????帮帮忙啊

kuguanet 2004-05-07 09:29:48
Private Sub Command3_Click()
Dim WI, QI, CPi, Bth, CPj, CJ, RK, CPk, Shk, F5, PI As Long
PI = 3.14159265358979

Text1.Text = WI
Text2.Text = QI
Text3.Text = CPi
Text4.Text = Bth
Text5.Text = CPj
Text6.Text = CJ
Text7.Text = RK
Text8.Text = CPk
Text9.Text = Shk

Dim a, b, c, d, e, f
a = (WI + QI) * Cos(CPi * PI / 180)
b = (RK + Shk) * Sin(CPk * PI / 180) * Tan(CPj * PI / 180 / 180)
c = CJ * (Bth / Cos(CPi * PI / 180))
d = CLng((RK / Shk) * Cos(CPk * PI / 180))
e = (WI + QI) * Sin(CPi * PI / 180)
F5 = (a + b + c + d) / e
Text10.Text = F5
Print Text10.Text

End Sub

d =(RK / Shk) * Cos(CPk * PI / 180)

...全文
65 7 打赏 收藏 举报

7 条回复

ZJYUNCSUNDN 2004-05-07
Private Sub Command1_Click()

Dim WI As Single, QI As Single, CPi As Single, Bth As Single, CPj As Single, CJ As Single, RK As Single, CPk As Single, Shk As Single, F5 As Single
Const PI = 3.14159265358979

WI = 1
QI = 1
CPi = 1
Bth = 1
CPj = 1
CJ = 1
RK = 1
CPk = 1
Shk = 1

Text1.Text = WI
Text2.Text = QI
Text3.Text = CPi
Text4.Text = Bth
Text5.Text = CPj
Text6.Text = CJ
Text7.Text = RK
Text8.Text = CPk
Text9.Text = Shk

Dim a As Single, b As Single, c As Single, d As Single, e As Single, f As Single
a = (WI + QI) * Cos(CPi * PI / 180)
b = (RK + Shk) * Sin(CPk * PI / 180) * Tan(CPj * PI / 180 / 180)
c = CJ * (Bth / Cos(CPi * PI / 180))
d = RK / Shk * Cos(CPk * PI / 180)
e = (WI + QI) * Sin(CPi * PI / 180)
F5 = (a + b + c + d) / e
Text10.Text = F5
Print Text10.Text

d = (RK / Shk) * Cos(CPk * PI / 180)

End Sub
• 打赏
• 举报

kuguanet 2004-05-07
Text1.Text = WI
Text2.Text = QI
Text3.Text = CPi
Text4.Text = Bth
Text5.Text = CPj
Text6.Text = CJ
Text7.Text = RK
Text8.Text = CPk
Text9.Text = Shk

• 打赏
• 举报

junglerover 2004-05-07
？？？不是所有数据都变成0，而是所有数据都本来就是0么。你定义了那么多变量，却一个也没有赋值，不是0才怪？？？？

SHK=0 ，所以 RK / 0 溢出。不溢出才怪呢。有什么问题？？？

• 打赏
• 举报

kuguanet 2004-05-07
d = (RK / Shk) * Cos(CPk * PI / 180)

• 打赏
• 举报

fanr520 2004-05-07

• 打赏
• 举报

wangh2122 2004-05-07

PI As Long

PI = 3.14159265358979
• 打赏
• 举报

victorycyz 2004-05-07

Dim WI As Long, QI As Long, CPi As Long, Bth As Long, CPj As Long, CJ As Long, RK As Long, CPk As Long, Shk As Long, F5 As Long, PI As Long
• 打赏
• 举报

7597

VB 基础类

2004-05-07 09:29