除了textbox1中的十进制值 [英] except only decimal values in textbox1
本文介绍了除了textbox1中的十进制值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个文本框和一个按钮。在一个textbox1中我插入十进制值,它正在转换为单词。我的代码如下。但是当我在文本框中插入int或string时,它会抛出错误。
我希望当我在文本框中发送int或string时,应显示一个消息框。
i have two textboxes and one button.in one textbox1 i am inserting decimal value and it is converting into words. my codes are below. but when i am inserting int or string into textbox one then it is throwing errors.
i want one message box should be display when i sent int or string inside the textbox one.
if ("" == feespaybletothecounsel.Text )
{
MessageBox.Show("please check");
}
else
{
string convertys = ConverttoWords(Convert.ToInt32(feespaybletothecounsel.Text));
if (convertys == "" )
{
feespaybletothecounsel.Text = "";
}
feespaybletothecounsel1.Text = convertys;
}
推荐答案
使用int.TryParse
useint.TryParse
int val;
if(!int.TryParse(feespaybletothecounsel.Text, out val)
{
MessageBox.Show("please check");
}else
{
feespaybletothecounsel1.Text = ConverttoWords(val);
}
这篇关于除了textbox1中的十进制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文