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

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 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
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

为什么这些值都赋不进去,的确都是0
谢谢提醒啊
  • 打赏
  • 举报
回复
junglerover 2004-05-07
???不是所有数据都变成0,而是所有数据都本来就是0么。你定义了那么多变量,却一个也没有赋值,不是0才怪????

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

我看是不是你的中间一串赋值语句都写反了?
  • 打赏
  • 举报
回复
kuguanet 2004-05-07
d = (RK / Shk) * Cos(CPk * PI / 180)
在这句上还是会溢出,大虾,请帮忙调试一下吧
溢出以后所有的数据都变成0了
  • 打赏
  • 举报
回复
fanr520 2004-05-07
如果在DIM中没的指出类型,则默认为可变类型,
定义同楼上
  • 打赏
  • 举报
回复
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
  • 打赏
  • 举报
回复
相关推荐
发帖
VB基础类
加入

7597

社区成员

VB 基础类
社区管理员
  • VB基础类社区
申请成为版主
帖子事件
创建了帖子
2004-05-07 09:29
社区公告
暂无公告