误差总和。我该怎么办呢?

编程入门 行业动态 更新时间:2024-10-09 15:17:08
本文介绍了误差总和。我该怎么办呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

i67.tinypic/5kfyo0.jpg

如何解决这笔款项。 1 + 2 = 12不是3.这是我的代码vb

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() [ ^ ]来实现这一目标。

i67.tinypic/5kfyo0.jpg

How can i fix that sum. 1+2 = 12 not 3. This my code vb

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.

更多推荐

误差总和。我该怎么办呢?

本文发布于:2023-11-02 06:08:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551579.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:我该   误差   总和

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!