将双数转换为Word [英] Convert Double Number to Word

查看:73
本文介绍了将双数转换为Word的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我是新会员,这是我的第一个问题。



我有一个带有2个文本框(txtNumber和txtWord)和一个按钮(btnConvert)的Windows窗体应用程序。



在第一个文本框中我必须只插入双数字,所以我写了这段代码:

  void  TxtNumeroKeyPress( object  sender,KeyPressEventArgs e)
{
bool Carattere = false ;

if (Char.IsDigit(e.KeyChar)|| e.KeyChar == ' \ b'
{
// Non lettere e spazi
}
else if (e.KeyChar == ' 。'&&!Carattere)
{
// Scrive numeri e punto
Carattere = ;
}
else
{
e.Handled = true ;
}
}





问题:



我想通过按下转换按钮,第一个文本框中存在的数字(txtNumber)将被转换为相应的单词并出现在第二个文本框中(txtWord) )。

你能帮助我吗?



如果我的英语不是最好的,我很抱歉。 ^^



Nick

解决方案

你需要创建你的字典或翻译库输入数字并将相应地转换它。

假设您在第一个文本框中输入21;在那种情况下

找到的数字的总数是2.所以,使用基础数学,你可以这样做

单位 - > 1

十 - > 2



单位= {one,two,three,...}

Tens = {Twenty,Thirty,Fourty,... }



现在,您需要检查Unit对应于1的时间,以及哪个Tens对应2,然后相应地进行翻译和合并以将其转换为单词。

Hi everyone,

I'm a new member and this is my first question.

I have a Windows Form application with 2 textbox (txtNumber and txtWord) and a button (btnConvert).

In the first textbox I must to insert only double numbers, so I wrote this code:

void TxtNumeroKeyPress(object sender, KeyPressEventArgs e)
{		
    bool Carattere = false;

    if (Char.IsDigit(e.KeyChar) || e.KeyChar == '\b')
    {
        // Non lettere e spazi
    }
    else if (e.KeyChar == '.' && !Carattere)
    {
         //Scrive numeri e punto
         Carattere = true;
    }
    else
    {
         e.Handled = true;
    }
}



Question:

I would like, by pressing the Convert button, that the number present in the first textbox (txtNumber) is converted in it's respective word and appears in the second textbox (txtWord).
Can you help me?

I'm sorry if my English isn't the best. ^^

Nick

解决方案

You need to create your on dictionary or the translating library which take the input number and will convert it accordingly.
Lets say you enter 21 in first text box; in that case
Total digits in the number found are 2. So, using basic mathematics, you can do it as
Unit -> 1
Ten -> 2

Units = {one, two, three, ...}
Tens = {Twenty, Thirty, Fourty, ...}

Now, you need to check when Unit corresponds to 1, and which Tens correspond to 2 and then translate and merge it accordingly to convert it to words.


这篇关于将双数转换为Word的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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