[求助] 在 VB2005 中获取一个数的各位的数值的问题!
俺是VB的初学者,刚学没有半个月,最近帮公司财务做一个出款单的打印程序,在分析把一个小写金额总数按各位数拆分为若干值并转换为中文大写后分别填到指定的“万”“仟”“佰”......前面时发现问题!在数值为 **.02-04;**.11-13 左右时,获得的分位数比实际值小1,不知何故?请各位兄弟姐妹指导指导,附相关代码如下:
Dim a, b, c, d, f, g, h As Int32
Dim k, x As Double
k = TextBox8.Text
x = Abs(k)
a = Fix(x / 10000) '提出万位整数
b = Fix((x - (a * 10000)) / 1000) '提出千位整数
c = Fix(((x - a * 10000 - b * 1000)) / 100) '提出百位整数
d = Fix((x - a * 10000 - b * 1000 - c * 100) / 10) '提出十位整数
f = Fix(x - a * 10000 - b * 1000 - c * 100 - d * 10) '提出个位整数
g = Fix((x - a * 10000 - b * 1000 - c * 100 - d * 10 - f) * 10) '提出小数点后第一位整数
h = Fix(((x - a * 10000 - b * 1000 - c * 100 - d * 10 - f) * 100) - g * 10) '提出小数点后第二位整数
If k >= 10000.0 Then
ComboBox3.Text = a
Select Case a
Case 1
ComboBox3.Text = "壹"
Case 2
ComboBox3.Text = "贰"
Case 3
ComboBox3.Text = "叁"
Case 4
ComboBox3.Text = "肆"
Case 5
ComboBox3.Text = "伍"
Case 6
ComboBox3.Text = "陆"
Case 7
ComboBox3.Text = "柒"
Case 8
ComboBox3.Text = "捌"
Case 9
ComboBox3.Text = "玖"
End Select
ComboBox4.Text = b
Select Case b
Case 1
ComboBox4.Text = "壹"
Case 2
ComboBox4.Text = "贰"
Case 3
ComboBox4.Text = "叁"
Case 4
ComboBox4.Text = "肆"
Case 5
ComboBox4.Text = "伍"
Case 6
ComboBox4.Text = "陆"
Case 7
ComboBox4.Text = "柒"
Case 8
ComboBox4.Text = "捌"
Case 9
ComboBox4.Text = "玖"
Case 0
ComboBox4.Text = "零"
End Select
.
.
.
.
.
.
[此贴子已经被作者于2007-7-30 11:10:17编辑过]