谁能提供人民币转大写的算法(C#)?1000分送

能否提供??要求满足千兆位到厘毫位:如1234123412341234.1234
---------------------------------------------------------------

一千分,没那么夸张吧。下面是我捡来的一个代码改的。有问题再找我。
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace WindowsApplication14
{
///

1<summary>   
2/// Form2 的摘要说明。   
3/// </summary>

public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button button1;
///

1<summary>   
2/// 必需的设计器变量。   
3/// </summary>

private System.ComponentModel.Container components = null;

public Form2()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

///

1<summary>   
2/// 清理所有正在使用的资源。   
3/// </summary>

protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///

1<summary>   
2/// 设计器支持所需的方法 - 不要使用代码编辑器修改   
3/// 此方法的内容。   
4/// </summary>

private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(184, 80);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(184, 112);
this.textBox2.Name = "textBox2";
this.textBox2.TabIndex = 1;
this.textBox2.Text = "textBox2";
//
// button1
//
this.button1.Location = new System.Drawing.Point(200, 168);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(480, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1,
this.textBox2,
this.textBox1});
this.Name = "Form2";
this.Text = "Form2";
this.Load += new System.EventHandler(this.Form2_Load);
this.ResumeLayout(false);

}
#endregion

private void Form2_Load(object sender, System.EventArgs e)
{

}

private void button1_Click(object sender, System.EventArgs e)
{
double wlNum =double.Parse(textBox1.Text);

string wlAmt,wkCd ;
wkCd="";
wlAmt=wlNum.ToString("f").PadLeft(12);
for(int i=0;i<=11;i++)
{
if (i!=9)
{
wkCd +=yGetChg(wlAmt.Substring(i,1),i,wlAmt);
}
}
textBox1.Text=wlAmt;
textBox2.Text=wkCd.Trim();
}

string yGetChg(string wlCd , int wlLoc , string wlAmtt )
{
string wlDd="億仟佰拾萬仟佰拾元 角分";
string wlName="";
string wlTemp=wlAmtt.Substring(1,1)+wlAmtt.Substring(2,1)+wlAmtt.Substring(3,1)+ wlAmtt.Substring(4,1)+"0";
int wlTemp2=int.Parse( wlTemp);
switch (wlCd)
{
case "1":
wlName="壹" + wlDd.Substring(wlLoc,1);
break;
case "2":
wlName= "貳" + wlDd.Substring(wlLoc, 1);
break;
case "3":
wlName="參" +wlDd.Substring(wlLoc,1);
break;
case "4":
wlName="肆" + wlDd.Substring(wlLoc, 1);
break;
case "5":
wlName="伍" + wlDd.Substring(wlLoc, 1);
break;
case "6":
wlName="陸" + wlDd.Substring(wlLoc, 1);
break;
case "7":
wlName="柒" + wlDd.Substring(wlLoc, 1);
break;
case "8":
wlName="捌" + wlDd.Substring(wlLoc, 1);
break;
case "9":
wlName="玖" + wlDd.Substring(wlLoc, 1);
break;
case "0":
if(wlLoc<11)
{
if(("1234567").IndexOf(wlLoc.ToString())>0 & ("0").IndexOf(wlAmtt.Substring(wlLoc+1,1))<0)
{
wlName="零";
}
if(wlAmtt.Substring(wlLoc+1,1)==".")
{
wlName=wlDd.Substring(wlLoc,1);
}
if(wlLoc==4 & wlTemp2>0 )
{
wlName= "萬";
}
}
break;
}
return wlName.Trim();
}
}
}

Published At
Categories with Web编程
Tagged with
comments powered by Disqus