興趣嗜好

跳至

首頁
12

尾頁
   1


大宅

積分: 1530


21#
發表於 09-4-30 13:45 |只看該作者
搞掂咗了,真係好開心有咁多好好的人幫我呢種電腦白痴.

好多謝多謝啊!

所以話世界係美好,咁多好人熱心幫人!

小必理痛 你的意思係埋話如果我係一個file度設著個巨集,無得開出來改返,要重新開個再設個?但我之前因為設錯咗(都係我已較好位置各個開支票file),我一入speelnumber(a1)佢就自動彈出來話我輸入錯誤,跟住彈出我之前設各個巨集,點解會咁啊?

唔該晒!


原帖由 小必理痛 於 09-4-30 12:54 發表
唔好咁講,咁岩得咁橋出正一D我有興趣嘅問題,咪大家一齊玩一齊研究下囉!呵呵!


大宅

積分: 1366


22#
發表於 09-4-30 14:06 |只看該作者
原帖由 kittymam 於 09-4-30 13:45 發表
搞掂咗了,真係好開心有咁多好好的人幫我呢種電腦白痴.

好多謝多謝啊!

所以話世界係美好,咁多好人熱心幫人!

小必理痛 你的意思係埋話如果我係一個file度設著個巨集,無得開出來改返,要重新開個再設個?但我之前因為 ...


唔係,我嘅意思係話如果你係某一個Excel file裡面設左巨集,咁就只限於呢個file使用,如果去到另一個Excel file,你想再用呢個巨集嘅話,就唔得囉,因為另一個Excel file係冇呢個巨集架嘛!除非你識得將巨集抄過去啦。

但其實Excel嘅巨集係可以存放o係一個叫做「個人巨集活頁簿」裡面,作為Excel嘅常駐程式使用,我就係咁樣做。

公司每一日都會有固定嘅report以Excel嘅形式生產出黎,但老闆們要將佢地summarize,我冇理由日日都要重複咁做幾廿個動作先可以做到佢地要嘅野,亦更加冇理由下下都要重寫巨集去執行呢D煩複嘅工作架!所以我就將寫好嘅巨集放o係「個人巨集活頁簿」裡面,隨時都可以用。


子爵府

積分: 13590


23#
發表於 09-4-30 16:45 |只看該作者
小必理痛

我有D亂可唔可以完整一個程式比我COPY?

123456.78 轉成

SAY HONG KONG DOLLARS ONE HUDNRED TWENTY THREE THOUAND FOUR HUNDRED FIFTY SIX AND CENTS SEVENTY EIGHT ONLY

唔該哂


男爵府

積分: 5436


24#
發表於 09-4-30 20:47 |只看該作者
原帖由 goofyszesze 於 09-4-30 16:45 發表
小必理痛

我有D亂可唔可以完整一個程式比我COPY?

123456.78 轉成

SAY HONG KONG DOLLARS ONE HUDNRED TWENTY THREE THOUAND FOUR HUNDRED FIFTY SIX AND CENTS SEVENTY EIGHT ONLY

唔該哂 ...

數字係要自己打入去o架喎!

呢樣唔得, o個樣唔得, 呢樣唔准, o個樣唔准......牛耕田,馬食穀,老豆賺錢女享福。


子爵府

積分: 13590


25#
發表於 09-4-30 20:51 |只看該作者
我知道....
因為之前既資料copy到好亂,我想小必理痛清楚我想出咩英文字。所以寫得詳細d‧

原帖由 spmok1999 於 09-4-30 20:47 發表

數字係要自己打入去o架喎!


男爵府

積分: 5436


26#
發表於 09-4-30 21:02 |只看該作者
原帖由 goofyszesze 於 09-4-30 20:51 發表
我知道....
因為之前既資料copy到好亂,我想小必理痛清楚我想出咩英文字。所以寫得詳細d‧

佢依家離線喎, 咁你等唔等佢丫?

如果唔等可以試下我呢個版本:

Option Explicit
'Main Function
Function SpellNumber(ByVal MyNumber)
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "
' String representation of amount.
MyNumber = Trim(Str(MyNumber))
' Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, ".")
' Convert cents and set MyNumber to dollar amount.
If DecimalPlace > 0 Then
Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
"00", 2))
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
End If
Count = 1
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 = "No Dollars"
Case "One"
Dollars = "One Dollar"
Case Else
Dollars = Dollars & ""
End Select
Select Case Cents
Case ""
Cents = ""
Case "One"
Cents = " and Cent One "
Case Else
Cents = " and" & " Cents " & Cents
End Select
SpellNumber = "Hong Kong Dollars " & Dollars & Cents & " Only"
End Function

' Converts a number from 100-999 into text
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 "
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.
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

呢樣唔得, o個樣唔得, 呢樣唔准, o個樣唔准......牛耕田,馬食穀,老豆賺錢女享福。


子爵府

積分: 13590


27#
發表於 09-4-30 22:33 |只看該作者
spmok1999

唔該哂你


大宅

積分: 1366


28#
發表於 09-5-1 00:15 |只看該作者
嘩....似乎好多人都好熱衷呢個Topic咁喎!

好啦,我就將我教樓主修改版嘅巨集Post出黎同大家分享。

另,goofyszesze要出嘅字串
可以寫成:="Say Hong Kong Dollars "&SpellNumber(A1) 當然,A1格一定要有數字。

再另外多謝spmok1999大哥幫忙答其他有需要嘅網友。 (好似講到我自己好威咁,哈哈!請勿介意)



Option Explicit

'Main Function
Function SpellNumber(ByVal MyNumber)

Dim Dollars, Cents, Temp
Dim DecimalPlace, Count

ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "

' String representation of amount.
MyNumber = Trim(Str(MyNumber))
' Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, ".")
' Convert cents and set MyNumber to dollar amount.
If DecimalPlace > 0 Then
Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & "00", 2))
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
End If

Count = 1
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
If Cents <> "" Then
Cents = " and " & IIf(Cents = "One", "Cent ", "Cents ") & Trim(Cents)
End If

SpellNumber = Dollars & Cents & " Only"

End Function

' Converts a number from 100-999 into text
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 "
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.
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

' Retrieve ones place.
Result = Result & GetDigit(Right(TensText, 1))
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

首頁
12

尾頁

跳至
Presslogic Logo
Baby Kingdom Logo