帮我看看这段代码,急

edisonlzk 2007-04-10 05:23:31
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;



namespace currency
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
this.textBox2.ReadOnly = true;
this.button2.Enabled = false;
this.TopMost = true;


}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
this.button2.Enabled = true;
this.label2.Text = "美元";
}
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked)
{
this.button2.Enabled = true;
this.label2.Text = "英镑";
}

}

private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
if (radioButton3.Checked)
{
this.button2.Enabled = true;
this.label2.Text = "日元";
}
}

private void button1_Click(object sender, EventArgs e)
{
if (this.textBox1.Text.Length == 0)
{
MessageBox.Show("wrong");
}
else
{
string str = this.textBox1.Text;
string r = @"[1-9]\d+";
str = System.Text.RegularExpressions.Regex.Match(str, r).ToString(); //RegularExpressions to match the number
if (radioButton1.Checked)
{
double num = (double.Parse(str)) / 8.0;
string str1 = num.ToString();
this.textBox2.Text = str1;
}
if (radioButton2.Checked)
{
double num = (double.Parse(str)) / 10.0;
string str1 = num.ToString();
this.textBox2.Text = str1;
}
if (radioButton3.Checked)
{
double num = (double.Parse(str)) * 10.0;
string str1 = num.ToString();
this.textBox2.Text = str1;
}

}
}

private void button2_Click(object sender, EventArgs e)
{
this.textBox1.Text = "";
this.textBox2.Text = "";
this.label2.Text = "美元";
}

private void button3_Click(object sender, EventArgs e)
{
Application.Exit();
}

private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar != 8) && (e.KeyChar !=0 ) && (e.KeyChar != 46))
{
e.Handled = true;
}
}
}
}

为什么我输入带有小字点的数字后,小数点后面的数却不能参与运算?
比如我输入45.5,乘以10以后就本该是455,但是却输入450
原因?????????????????
...全文
173 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
edisonlzk 2007-04-10
  • 打赏
  • 举报
回复
顶上去...!!!
edisonlzk 2007-04-10
  • 打赏
  • 举报
回复
我是写的winform程序,哪来ASPX页,?
QFord 2007-04-10
  • 打赏
  • 举报
回复
你是winform程序,我自己建了看看
QFord 2007-04-10
  • 打赏
  • 举报
回复
你把aspx页的代码也贴出来,我看看
AdamLin 2007-04-10
  • 打赏
  • 举报
回复
挂断点单步调试
edisonlzk 2007-04-10
  • 打赏
  • 举报
回复
那应该怎么改呀,我用的DOUBLE
绝代坏坏 2007-04-10
  • 打赏
  • 举报
回复
数据类型不对.

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧