| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 625 人关注过本帖
标题:求助计算问题
只看楼主 加入收藏
shunlai
Rank: 1
等 级:新手上路
威 望:1
帖 子:228
专家分:0
注 册:2006-2-1
结帖率:94.12%
收藏
 问题点数:0 回复次数:3 
求助计算问题
各位高人你们好:本人打算让Text44.Text文本框中,在计算数值大于零时显示计算值,而在计算数值小于零时显示“0”。如下是本人编的语句,问题是在按Command键计算时(在Text44.Text文本框中得数应该是负数的条件下),按一下得“0”、再按一下就得“负数”。如何实现按计算Command键时,程序正确判断得到唯一得数?
If Val(Text44.Text) >= 0 Then
fg = (Val(Text1.Text) + Val(Text2.Text)) - Val(Text3.Text) * (Val(Text1.Text) + Val(Text2.Text)) * (Val(Text1.Text) + Val(Text2.Text)) / (Val(Text1.Text) * Val(Text9.Text) + Val(Text2.Text) * Val(Text10.Text) + 0.000001)
Text44.Text = Format(fg, "##.0")
ElseIf Val(Text44.Text) < 0 Then
Text44.Text = "0"
End If

搜索更多相关主题的帖子: Val Command 数值 负数 文本 
2007-03-14 10:00
Kendy123456
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:62
帖 子:2720
专家分:0
注 册:2007-1-3
收藏
得分:0 
你是先计算 然后把值放到text44。 现在还没算就先用text44做判断当然不对了

这样就不会错了:

fg = (Val(Text1.Text) + Val(Text2.Text)) - Val(Text3.Text) * (Val(Text1.Text) + Val(Text2.Text)) * (Val(Text1.Text) + Val(Text2.Text)) / (Val(Text1.Text) * Val(Text9.Text) + Val(Text2.Text) * Val(Text10.Text) + 0.000001)

If fg >= 0 Then
Text44.Text = Format(fg, "##.0")
Else
Text44.Text = "0"
End If

2007-03-14 10:37
zsolong
Rank: 1
等 级:新手上路
威 望:1
帖 子:193
专家分:0
注 册:2006-12-15
收藏
得分:0 

楼上OK


2007-03-14 11:00
wenber0598
Rank: 1
等 级:新手上路
帖 子:101
专家分:0
注 册:2007-2-27
收藏
得分:0 

顶!


三人行必有我师
2007-03-14 11:16
快速回复:求助计算问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.010710 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved