1樓:
'定義陣列:
dim chap(21, 1)
'初始化:
chap(0, 0) = "萬": chap(0, 1) = 10000
chap(1, 0) = "仟": chap(1, 1) = 1000
chap(2, 0) = "佰": chap(2, 1) = 100
chap(3, 0) = "拾": chap(3, 1) = 10
chap(4, 0) = "元": chap(4, 1) = 1
chap(5, 0) = "角": chap(5, 1) = 0.1
chap(6, 0) = "分": chap(6, 1) = 0.01
chap(11, 0) = "壹": chap(11, 1) = 1
chap(12, 0) = "貳": chap(12, 1) = 2
chap(13, 0) = "叄": chap(13, 1) = 3
chap(14, 0) = "肆": chap(14, 1) = 4
chap(15, 0) = "伍": chap(15, 1) = 5
chap(16, 0) = "陸": chap(16, 1) = 6
chap(17, 0) = "柒": chap(17, 1) = 7
chap(18, 0) = "捌": chap(18, 1) = 8
chap(19, 0) = "玖": chap(19, 1) = 9
chap(20, 0) = "零": chap(20, 1) = 0
chap(21, 0) = "億": chap(21, 1) = 100000000
function subtochinese(price as integer)
轉化千百十
dim i as integer
dim num(15) as integer
i = 1
do until price = 0
num(i) = int(price / chap(i, 1))
if num(i) <> 0 then
subtochinese = subtochinese & chap(num(i) + 10, 0) & chap(i, 0)
price = price - num(i) * chap(i, 1)
else
if subtochinese <> "" and right(subtochinese, 1) <> "零" then
subtochinese = subtochinese & "零"
end if
end if
i = i + 1
loop
if right(subtochinese, 1) = "元" then
subtochinese = left(subtochinese, len(subtochinese) - 1)
end if
end function
function pricetochinese(price as double)
if price >= 100000000 then 大於1億
pricetochinese = pricetochinese & pricetochinese(int(price / 100000000)) & "億"
price = price - int(price / 100000000) * 100000000
end if
if price >= 10000 then
pricetochinese = pricetochinese & subtochinese(int(price / 10000)) & "萬"
price = price - int(price / 10000) * 10000
end if
if int(price) <> 0 then 如果萬與千間無數,則應添零
if pricetochinese <> "" and int(price) < 1000 then
pricetochinese = pricetochinese & "零"
end if
pricetochinese = pricetochinese & subtochinese(int(price))
price = price - int(price)
end if
if pricetochinese <> "" then pricetochinese = pricetochinese & "元"
if price = 0 then 到元為止
pricetochinese = pricetochinese & "整"
else
price = int(price * 100)
if int(price / 10) <> 0 then
pricetochinese = pricetochinese & chap(int(price / 10) + 10, 0) & "角"
price = price - int(price / 10) * 10
end if
if price <> 0 then
pricetochinese = pricetochinese & chap(int(price) + 10, 0) & "分"
end if
end if
end function
2樓:伊人尤在
'本**輸出格式為類似發票上的金額填寫格式,非讀法格式.
private sub form_click()
randomize
b = array("分", "角", "元", "拾", "佰", "仟", "萬", "拾", "佰", "仟", "億")
s = array("零", "壹", "貳", "叄", "肆", "伍", "陸", "柒", "捌", "玖")
m = 100000000 '最大金額
x = format(int(rnd * m * 100) / 100, "0.00")
text1.text = x & "元"
y = cstr(x * 100) '從最高非零位處理
'y = cstr(format(x * 100, "00000000000")) '從億位開始處理
dx = ""
for i = len(y) to 1 step -1
dx = mid(y, i, 1) & b(len(y) - i) & dx
next i
for i = 0 to 9
dx = replace(dx, i, s(i))
next i
dx = replace(dx, "零角零分", "整")
text2.text = dx
end sub
怎麼在vb中限定文字框大小,讓文字自動換行
在窗體設計過程中,使multiline true scrollbars 2就可以了。但不能在程式執行中改變這兩個屬性 1 在設計狀態下 把文字框的 multiline 屬性 設為true,就是允許文字框可以顯示多行文字。2 如果版 內容較多時把權scrollbars設為 2 vertical,這樣可...
VB在文字框中輸入字母,單擊button1,轉換為大寫字母,單擊button2,轉換為小寫字母
這樣可以不?private sub command1 click dim x as string dim y as string dim s as string x text1.text if option1.value true thenfor i 1 to len x y mid x,i,1 i...
在中繪製完文字框想在文字框外輸入文字,如何把游標移到文字框下方
把游標移到文字框外,如果游標在上面你就多按幾個回車,然後把文字框向上移動就可以了。把文字框拉開,輸入文字,再留空,把文字框放回原地,其實我一直覺得文字框不太好用 word中在繪製的文字框中輸入文字從左到右怎麼設定 word中繪製的文字框中輸入文字預設就是從左到右的,不用設定,如果要橫排變成豎排,要設...