击中等于按钮时错过计算 [英] Miss calculate when hitting equals button

查看:74
本文介绍了击中等于按钮时错过计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,程序员,首先,我要感谢大家的大力帮助. Sirs ive在这里遇到了另一个问题,因为您看到ive创建了5个文本框,其中前四个实际上会彼此相乘,而解决方案转到第5个文本框.我的问题是,当它是一个整数(1,2,3,4等)时,公式就可以正确地解决它,但是如果它是一个十进制数,那么答案是错误的.请帮助不知道语法.
这是我的代码:

hello programmers, first of all i would like thank you all for your big help. Sirs ive got another problem here as you see ive created 5 textboxes where the first four would actually multiply to each other and the solution goes to the fifth textbox. My problem is when it is a whole number (1,2,3,4,etc) the formula is solving it the right way, but if it is a decimal number the the answer is wrong. Please help dont know the syntax.
Here is my code:

If IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) And IsNumeric(TextBox3.Text) AndAlso IsNumeric(TextBox4.Text) Then
          TextBox5.Text = CInt(TextBox1.Text) * CInt(TextBox2.Text) * CInt(TextBox3.Text) * CInt(TextBox4.Text)
      End If

推荐答案

嗨.我从未在VB中进行编码,但是我认为也许您应该使用CSng而不是CInt.

http://msdn.microsoft.com/en-us/library/s2dy91zy%28v = vs.80%29.aspx [ ^ ]
Hi. I''ve never coded in VB, but I think that maybe you should use CSng instead of CInt.

http://msdn.microsoft.com/en-us/library/s2dy91zy%28v=vs.80%29.aspx[^]


<br />
TextBox5.Text = CDbl(TextBox1.Text) * CDbl(TextBox2.Text) * CDbl(TextBox3.Text) * CDbl(TextBox4.Text)<br />
<br />


这篇关于击中等于按钮时错过计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆