当前位置:编程学习 > C#/ASP.NET >>

C#编写的计算器退格键到头出错了 急~~~

 textBox1.Text = textBox1.Text.Remove(textBox1.SelectionStart-1,1); 当退到头的时候程序就报错了~各位大大们 求帮忙~ --------------------编程问答-------------------- 加判断
if(textBox1.Text.ToString().Trim().Length>0)
{} --------------------编程问答-------------------- 楼上正解 --------------------编程问答--------------------

if(textBox1.Text.ToString().Trim().Length>0)
{
   textBox1.Text = textBox1.Text.Remove(textBox1.SelectionStart-1,1);
}
--------------------编程问答-------------------- if(String.IsNullOrEmpty(TextBox1.Text))
{
return;
}
else
{
//执行你上面的代码;
} --------------------编程问答-------------------- textBox1.Text.ToString() ? --------------------编程问答-------------------- if (textBox1.Text.Length > 0)
  {
  textBox1.Text = textBox1.Text.Remove(textBox1.Text.Length - 1);
  }
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,