误差总和。我该怎么办呢? [英] Error sum. How I can fix it?
本文介绍了误差总和。我该怎么办呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
http://i67.tinypic.com/5kfyo0.jpg
如何解决这笔款项。 1 + 2 = 12不是3.这是我的代码vb.net
Private Sub btnHitung_Click(sender as Object,e As EventArgs)处理btnHitung 。点击
txtJumlahB.Text =(txtStokSisa.Text + txtBarangM.Text)
结束子
谢谢
我尝试过:
i try sum来自谷歌搜索。但我找不到相同的错误。
解决方案
TextBox始终返回字符串,从不返回整数。字符串1与整数不一样,1。
您将两个字符串连接在一起,1+2= 12。
您必须将字符串转换为整数才能将它们组合在一起。查看 Integer.TryParse() [ ^ ]来实现这一目标。
http://i67.tinypic.com/5kfyo0.jpg
How can i fix that sum. 1+2 = 12 not 3. This my code vb.net
Private Sub btnHitung_Click(sender As Object, e As EventArgs) Handles btnHitung.Click txtJumlahB.Text = (txtStokSisa.Text + txtBarangM.Text) End Sub
thanks before
What I have tried:
i try sum from google search. but i can't find the same wrong with this.
解决方案
TextBox's always return strings, never integers. A string, "1", is not the same as an integer, 1.
You're concatenating two strings together, "1" + "2" = "12".
You have to convert the string to integers in order to add them together. Look into Integer.TryParse()[^] to accomplish that.
这篇关于误差总和。我该怎么办呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文