求指教:怎么才能让我的数字能输入几位,显示几位的大学。
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 大小转化
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int z, g, s, b, q, i;
string a;
a = textBox1.Text;
z = Convert.ToInt32(a);
i = a.Length;
g = z % 10;
s = z / 10 % 10;
b = z / 100 % 10;
q = z / 1000 % 10;
if (i > 2 & i < 3)
{
}
if (i > 4)
{
MessageBox.Show("你输入的数字以超出范围", "提示信息");
}
else
{
switch (q)
{
case 9: label1.Text = "玖"; break;
case 8: label1.Text = "捌"; break;
case 7: label1.Text = "柒"; break;
case 6: label1.Text = "陆"; break;
case 5: label1.Text = "伍"; break;
case 4: label1.Text = "肆"; break;
case 3: label1.Text = "叁"; break;
case 2: label1.Text = "贰"; break;
case 1: label1.Text = "壹"; break;
case 0: label1.Text = "零"; break;
}
switch (b)
{
case 9: label1.Text = label1.Text + "玖"; break;
case 8: label1.Text = label1.Text + "捌"; break;
case 7: label1.Text = label1.Text + "柒"; break;
case 6: label1.Text = label1.Text + "陆"; break;
case 5: label1.Text = label1.Text + "伍"; break;
case 4: label1.Text = label1.Text + "肆"; break;
case 3: label1.Text = label1.Text + "叁"; break;
case 2: label1.Text = label1.Text + "贰"; break;
case 1: label1.Text = label1.Text + "壹"; break;
case 0: label1.Text = label1.Text + "零"; break;
}
switch (s)
{
case 9: label1.Text = label1.Text + "玖"; break;
case 8: label1.Text = label1.Text + "捌"; break;
case 7: label1.Text = label1.Text + "柒"; break;
case 6: label1.Text = label1.Text + "陆"; break;
case 5: label1.Text = label1.Text + "伍"; break;
case 4: label1.Text = label1.Text + "肆"; break;
case 3: label1.Text = label1.Text + "叁"; break;
case 2: label1.Text = label1.Text + "贰"; break;
case 1: label1.Text = label1.Text + "壹"; break;
case 0: label1.Text = label1.Text + "零"; break;
}
switch (g)
{
case 9: label1.Text = label1.Text + "玖"; break;
case 8: label1.Text = label1.Text + "捌"; break;
case 7: label1.Text = label1.Text + "柒"; break;
case 6: label1.Text = label1.Text + "陆"; break;
case 5: label1.Text = label1.Text + "伍"; break;
case 4: label1.Text = label1.Text + "肆"; break;
case 3: label1.Text = label1.Text + "叁"; break;
case 2: label1.Text = label1.Text + "贰"; break;
case 1: label1.Text = label1.Text + "壹"; break;
case 0: label1.Text = label1.Text + "零"; break;
}
}
}
}
}