异常错误帮助 [英] Exception error help

查看:59
本文介绍了异常错误帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。我正在寻求关于我在Vb.net中收到的异常错误的建议。我创建了一个简单的每日支出表格。有Monies in,Monies Out和Balance Text Box输入。 余额文本框通过货币变更或货币输入自动调整。我遇到的问题是,如果有人输入了错误的值,并使用退格键删除并更正错误..当删除最后一个数字时,会发生异常错误....异常错误是类型'System.InvalidCastException的第一次机会异常'发生在Microsoft.VisualBasic.dll



附加信息:从字符串到Decimal类型的转换无效。



错误高点亮我的代码的这一部分... MoneyIn = txtIn1.Text



任何人都可以告诉我做错了什么



我的尝试:



Hello All. Im seeking advice on an exception error i am receiving in Vb.net. I have Created a simply Daily expenditure Forms. With a Monies in , Monies Out and Balance Text Box inputs. The Balance Text box is adjusted Automatically via the text Change of the Monies in or monies out Input. The Issue im having is if someone inputs incorrect value, and uses backspace to delete and correct the error .. when the last numerical is deleted an exception error occurs.... The exception error is A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll

Additional information: Conversion from string "" to type 'Decimal' is not valid.

The error high Lights this part of my code ... MoneyIn = txtIn1.Text

Could anyone advise what im doing wrong

What I have tried:

Dim BalFwd As Decimal
 Dim MoneyIn As Decimal
 Dim Balance As Decimal

Private Sub txtIn1_TextChanged(sender As Object, e As EventArgs) Handles txtIn1.TextChanged

 BalFwd = txtBalFwd.Text
 MoneyIn = txtIn1.Text
 Balance = MoneyIn + BalFwd
 txtB1.Text = Balance

推荐答案

参见 Int32.TryParse Method(System) [ ^ ]。


这篇关于异常错误帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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