数字转换为文字:
Function DLR2WRD(amt As Double)
Dim BUCKS(90)
Dim CAmt As String, WAmt As String, DCTR As Integer, DNums As String, DTens As D ouble
CAmt = Format(amt, "000000.00 ")
BUCKS(1) = "ONE "
BUCKS(2) = "TWO "
BUCKS(3) = "THREE "
BUCKS(4) = "FOUR "
BUCKS(5) = "FIVE "
BUCKS(6) = "SIX "
BUCKS(7) = "SEVEN "
BUCKS(8) = "EIGHT "
BUCKS(9) = "NINE "
BUCKS(10) = "TEN "
BUCKS(11) = "ELEVEN "
BUCKS(12) = "TWELVE "
BUCKS(13) = "THIRTEEN "
BUCKS(14) = "FOURTEEN "
BUCKS(15) = "FIFTEEN "
BUCKS(16) = "SIXTEEN "
BUCKS(17) = "SEVENTEEN "
BUCKS(18) = "EIGHTEEN "
BUCKS(19) = "NINETEEN "
BUCKS(20) = "TWENTY "
BUCKS(30) = "THIRTY "
BUCKS(40) = "FORTY "
BUCKS(50) = "FIFTY "
BUCKS(60) = "SIXTY "
BUCKS(70) = "SEVENTY "
BUCKS(80) = "EIGHTY "
BUCKS(90) = "NINETY "
WAmt = " "
DCTR = 1
vb编程基础知识函数Do While DCTR < 3
If DCTR = 1 Then
DNums = Mid(CAmt, 1, 3) Else
DNums = Mid(CAmt, 4, 3) End If
If Left(DNums, 1) > "0 " Then
WAmt = WAmt + BUCKS(Val(Lef t(DNums, 1))) + " HUNDRED "
End If
DTens = Val(Mid(DNums, 2, 2))
If DTens > 0 Then
If DTens > 20 Then
WAmt = WAmt + B UCKS(Val(Mid(DNums, 2, 1) + "0 "))
If Mid(DNums , 3, 1) > "0 " Then
WAmt = WAmt + "- " + BUCKS(Val(Mid(DNums, 3, 1))) + " "
Els e
WAmt = WAmt + " "
End If
Else
WAmt = WA mt + BUCKS(DTens) + " "
End If
End If
If amt > 999.99 And DCTR = 1 Then
WAmt = WAmt + "THOUSAND "
End If
DCTR = DCTR + 1
Loop
DLR2WRD = IIf(amt < 1, "ONLY ", WAmt + "AND ") + Right(CAmt, 2) + "/100 DOLLAR " + IIf(amt = 1, " ", "S ")
End Function
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'****以下是一个读ini文件的函数**** '
Public Function GetIniStr(ByVal FileName As Stri ng, _
ByVal Section As String, _
ByVal Key As String) As String
On Error Resume Next
Dim strRetVal As String
Dim strVer As String
Dim strDefValue As String
strDefValue = " "
GetIniStr = strDefValue
strRetVal = String$(255, 0)
GetPrivateProfileString Section, Key, strD efValue, strRetVal, _
Len(strRetVal), FileName
strVer = left(strRetVal, InStr(strRetVal, Chr(0)) - 1)
If strVer = " " Then
GetIniStr = strDefValue
Else
GetIniStr = strVer
End If
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论