Re: [VBA ] 數字轉中文大寫的問題

看板Visual_Basic作者 (清)時間19年前 (2005/10/04 14:51), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
※ 引述《yougetit1999 (清)》之銘言: : 請問我利用EXCEL本身的數字轉中文大寫的時候,11都轉成 : 壹拾壹,請問我要怎樣寫一個判斷式,當10~19時,都會去 : 掉前面的壹呢,因為10寫成壹拾真的蠻奇怪的... : 謝謝 我寫出一個方法,雖然可以用,但是好像有點笨 能否幫我看一下,是不是能在把程式精簡一下 Dim num As Integer num = ActiveCell.Value If num <= 0 Then MsgBox "輸入錯誤,數值小於0" ElseIf num > 0 And num < 10 Then ActiveCell.NumberFormatLocal = "[dbnum2]" ElseIf num > 19 Then ActiveCell.NumberFormatLocal = "[dbnum2]" ElseIf num = 10 Then ActiveCell.Value = "拾" ElseIf num = 11 Then ActiveCell.Value = "拾壹" ElseIf num = 12 Then ActiveCell.Value = "拾貳" ElseIf num = 13 Then ActiveCell.Value = "拾參" ElseIf num = 14 Then ActiveCell.Value = "拾肆" ElseIf num = 15 Then ActiveCell.Value = "拾伍" ElseIf num = 16 Then ActiveCell.Value = "拾陸" ElseIf num = 17 Then ActiveCell.Value = "拾柒" ElseIf num = 18 Then ActiveCell.Value = "拾捌" ElseIf num = 19 Then ActiveCell.Value = "拾玖" End If With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 203.70.60.138
文章代碼(AID): #13GYQ9B7 (Visual_Basic)
文章代碼(AID): #13GYQ9B7 (Visual_Basic)