我需要一个程序将阿拉伯数字转换成单词 [英] I need a program to convert Arabic Numbers into words

查看:79
本文介绍了我需要一个程序将阿拉伯数字转换成单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个可视化的基本程序将阿拉伯数字转换为文本或单词.
例子124改为"124"

我只是Visual Basic的新手.

我的想法就是这样


Dim num1,num2,num3作为整数
num1 = Val(txtNum.Text)
num2 = num1 Mod 100
num3 = num2 Mod 10

作为整数的Dim numH

如果1000> num1> = 900然后
numH =九百"
其他如果900> num1> = 800然后
numH =八百"
等等...


昏暗的numT为整数

如果100> num2> = 90然后
numT =九十"
否则90> num2> = 80然后
numT =八十"

等等...


Dim numO作为整数

如果num3或num1 = 9,则
numO =九个
ElseIf num3 = 8则
numO =八"


那么按钮的功能是这样的:

lblStatus.Caption = numH& numT& amp; amp; numO


我得到的所有值都将在标签中进行编译

所以如果我的电话号码是124,就会像
numH =一百"
numT =二十"
numO =一个"

因此lblStatus.caption =一百"& 二十" 一个"
像一百二十一"一样发出

正确吗?
我不能做我的主意,因为我只是VB的新手,我也不知道应该如何使用这些东西以及应该使用什么.

谢谢,也许您可​​以给我完整的源代码.

I need a visual basic program to convert Arabic Numbers to text or words.
Example 124 to "one hundred twenty four"

I''m just new to visual basic.

My idea is like this


Dim num1, num2, num3 As Integer
num1 = Val(txtNum.Text)
num2 = num1 Mod 100
num3 = num2 Mod 10

Dim numH As Integer

If 1000 > num1 >= 900 Then
numH = "nine hundred"
ElseIf 900 > num1 >= 800 Then
numH = "eight hundred"
so on...


Dim numT As Integer

If 100 > num2 >= 90 Then
numT = "ninety"
ElseIf 90 > num2 >= 80 Then
numT = "eighty"

so on...


Dim numO As Integer

If num3 Or num1 = 9 Then
numO = nine
ElseIf num3 = 8 Then
numO = "eight"


then the button''s function is this:

lblStatus.Caption = numH & numT & numO


all the values i got wil be compiled in the label

so if my number is 124 it''ll be like
numH = "one hundred"
numT = "twenty"
numO = "one"

so the lblStatus.caption = "one hundred" & "twenty" & "one"
it goes out like "one hundred twenty one"

Is it correct?
I can''t do my idea because I''m just new to VB and I don''t know how things should be used and what shoulud be used.

thanks, maybe you can give me the whole source code.

推荐答案

它在C#中,但是您应该可以轻松地进行转换:
http://www.codeproject.com/Tips/103025/Converting-数字到字词等效.aspx [ ^ ]
It''s in C#, but it should be easy for you to convert:
http://www.codeproject.com/Tips/103025/Converting-numbers-to-the-word-equivalent.aspx[^]


这篇关于我需要一个程序将阿拉伯数字转换成单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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