重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb.net中英文转换 vb转c语言工具

求用VB实现的数字转换英文的程序,不是货币转换,只数字就OK了,包括0的,跪求代码啊~~

Option Explicit

创新互联专注于昂昂溪网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供昂昂溪营销型网站建设,昂昂溪网站制作、昂昂溪网页设计、昂昂溪网站官网定制、小程序开发服务,打造昂昂溪网络公司原创品牌,更为您提供昂昂溪网站排名全网营销落地服务。

'Main Function

Function SpellNumber(ByVal MyNumber)

Dim Dollars, Cents, Temp, Cents1

Dim DecimalPlace, Count

ReDim Place(9) As String

Place(2) = " Thousand "

Place(3) = " Million "

Place(4) = " Billion "

Place(5) = " Trillion "

' 字符串表示的金额。

MyNumber = Trim(Str(MyNumber))

' Position of decimal place 0 if none.小数点后的位置0如果没有。

DecimalPlace = InStr(MyNumber, ".")

' Convert cents and set MyNumber to dollar amount.MyNumber转换美分和设置,金额。

If DecimalPlace 0 Then

Cents = Left(Mid(MyNumber, DecimalPlace + 1) _

"00", 2)

MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))

End If

Count = 1

Cents1 = GetCents(Cents)

Do While MyNumber ""

Temp = GetHundreds(Right(MyNumber, 3))

If Temp "" Then Dollars = Temp Place(Count) Dollars

If Len(MyNumber) 3 Then

MyNumber = Left(MyNumber, Len(MyNumber) - 3)

Else

MyNumber = ""

End If

Count = Count + 1

Loop

Select Case Dollars

Case ""

Dollars = ""

Case "One"

Dollars = "One"

Case Else

Dollars = Dollars

End Select

Select Case Cents1

Case ""

Cents1 = ""

Case "One"

Cents1 = " point One"

Case Else

Cents1 = " point " Cents1

End Select

SpellNumber = Dollars Cents1

Do While InStr(SpellNumber, " ") 0

SpellNumber = Replace(SpellNumber, " ", " ")

Loop

End Function

' Converts a number from 100-999 into text转换数字100 - 999进入文本

Function GetHundreds(ByVal MyNumber)

Dim Result As String

If Val(MyNumber) = 0 Then Exit Function

MyNumber = Right("000" MyNumber, 3)

' Convert the hundreds place.转换百的地方。

If Mid(MyNumber, 1, 1) "0" Then

Result = GetDigit(Mid(MyNumber, 1, 1)) " Hundred and "

End If

' Convert the tens and ones place.转换千的地方。

If Mid(MyNumber, 2, 1) "0" Then

Result = Result GetTens(Mid(MyNumber, 2))

Else

Result = Result GetDigit(Mid(MyNumber, 3))

End If

GetHundreds = Result

End Function

' Converts a number from 10 to 99 into text.转换数字从10到99成文本。

Function GetTens(TensText)

Dim Result As String

Result = "" ' Null out the temporary function value.空出暂时的函数值。

If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19...

Select Case Val(TensText)

Case 10: Result = "Ten"

Case 11: Result = "Eleven"

Case 12: Result = "Twelve"

Case 13: Result = "Thirteen"

Case 14: Result = "Fourteen"

Case 15: Result = "Fifteen"

Case 16: Result = "Sixteen"

Case 17: Result = "Seventeen"

Case 18: Result = "Eighteen"

Case 19: Result = "Nineteen"

Case Else

End Select

Else ' If value between 20-99...

Select Case Val(Left(TensText, 1))

Case 2: Result = "Twenty "

Case 3: Result = "Thirty "

Case 4: Result = "Forty "

Case 5: Result = "Fifty "

Case 6: Result = "Sixty "

Case 7: Result = "Seventy "

Case 8: Result = "Eighty "

Case 9: Result = "Ninety "

Case Else

End Select

Result = Result GetDigit _

(Right(TensText, 1)) ' Retrieve ones place.检索的地方。

End If

GetTens = Result

End Function

' Converts a number from 1 to 9 into text.

Function GetDigit(Digit)

Select Case Val(Digit)

Case 1: GetDigit = "One"

Case 2: GetDigit = "Two"

Case 3: GetDigit = "Three"

Case 4: GetDigit = "Four"

Case 5: GetDigit = "Five"

Case 6: GetDigit = "Six"

Case 7: GetDigit = "Seven"

Case 8: GetDigit = "Eight"

Case 9: GetDigit = "Nine"

Case Else: GetDigit = ""

End Select

End Function

Function GetCents(ByVal Cents)

Dim Result As String

Result = ""

If Val(Left(Cents, 1)) = 1 Then

Select Case Val(Cents)

Case 11: Result = "Eleven"

Case 12: Result = "Twelve"

Case 13: Result = "Thirteen"

Case 14: Result = "Fourteen"

Case 15: Result = "Fifteen"

Case 16: Result = "Sixteen"

Case 17: Result = "Seventeen"

Case 18: Result = "Eighteen"

Case 19: Result = "Nineteen"

Case Else

End Select

ElseIf Val(Mid(Cents, 2, 1)) = 0 Then

Select Case Val(Left(Cents, 1))

Case 2: Result = "Two"

Case 3: Result = "Three"

Case 4: Result = "Four"

Case 5: Result = "Five"

Case 6: Result = "Six"

Case 7: Result = "Seven"

Case 8: Result = "Eight"

Case 9: Result = "Nine"

Case Else

End Select

Else

Select Case Val(Left(Cents, 1))

Case 2: Result = "Twenty "

Case 3: Result = "Thirty "

Case 4: Result = "Forty "

Case 5: Result = "Fifty "

Case 6: Result = "Sixty "

Case 7: Result = "Seventy "

Case 8: Result = "Eighty "

Case 9: Result = "Ninety "

Case Else

End Select

Result = Result GetDigit _

(Right(Cents, 1))

End If

GetCents = Result

End Function

VB.NET 类似/u660e的字符串转换为中文

你可以用 Encoding 对象转。先用 Encoding.Unicode 转成 Byte(),再转回 Ansi。

也可以自己写代码,把/u替换为H,再逐个用ChrW()函数取得汉字即可。

VB.NET中MSGBOX按钮怎么变成英文

项目属性——应用程序——程序集信息——非特定语言,这里改为英语,然后messagebox框弹出来的就是英文的了,MSGBOX应该也是这样。

。net下推荐用messagebox而不是MSGBOX

VB 类型转换 LONG转成汉字(STRING)

读内存读出来的都是字节数组形式,看你读出来的数值赋给的变量是什么?还有就是你用的是vb还是vb.net,如果是vb,用chr()来将转换,遇到中英文汉字就麻烦点,需要将两个字节换为一个字(汉字占2字节原理)。如果是.net,直接用System.Text.Encoding.GetEncoding("gb2312").GetString( System.Text.Encoding.Convert(System.Text.Encoding.ASCII,System.Text.Encoding.GetEncoding("gb2312"),sourcebyte))其中System.Text.Encoding.ASCII是你读到的数组的编码,如果不是ascii,根据实际自己改。"gb2312"是你要转换为的文字的目标编码,如果不是gb2312,那你自己修改好了。

怎么用ToolTip来设置其显示的语言说明?(用于中英文切换时)(语言:VB.Net)

兄弟你可以用session["current"] = langgue ;来保存你的多语言的状态,页面载入的时候读sesion,;“中文”和“英文”切换的时候也读一下,多语言存放在res资源文件中就可以


本文名称:vb.net中英文转换 vb转c语言工具
新闻来源:http://cqcxhl.com/article/hijeic.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP