文本框中未显示双精度值 [英] double value not showing in textbox

查看:96
本文介绍了文本框中未显示双精度值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,.im是asp.net的新手.即时通讯试图在基于单选按钮的文本框中显示一个双精度值,但未显示它.这是使用
的代码

hello guys..im new to asp.net. im trying to show a double value in textbox based on radio button but it is not showing it. Here is the code im using

double res = 0;
double num1 = Convert.ToDouble(txt1.Text);
double num2 = Convert.ToDouble(txt2.Text);

if (radioAdd.Checked )
    res = num1 + num2;
else if (radioSub.Checked == true)
    res = num1 - num2;
else if (radioMul.Checked == true)
    res = num1 * num2;
else
    res = num1 / num2;

txtResult.Text += res.ToString();

推荐答案

您何时尝试显示该值?好像您错过了一个事件.

步骤:
1.用户界面具有单选按钮和2个文本框用于输入,一个文本框用于结果,一个按钮用于显示结果
2.选择单选按钮,将值放在两个文本框中,然后单击显示结果按钮.
3.在按钮单击事件上,将上面的代码放入,您可以在结果文本框中看到计算的结果.
When are you trying to show the value? Looks like you are missing an event.

Steps:
1. UI has radio button and 2 textbox for input and one for result and one button for show result
2. Select radibutton, put values in two textboxes and click show result button.
3. On button click event, put the above code and you can see the computed result in result textbox.




试试这个

txtResult.Text = string.Format("{0:d}",res);

希望对您有所帮助
Hi,

try this

txtResult.Text = string.Format("{0:d}",res);

Hope this will help


这篇关于文本框中未显示双精度值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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