[急]vb从Excel中读数据

painAndhappy 2003-07-16 10:35:07
vb从Excel中读数据时,比如单元格I3的数据为数值12.34,而G3单元格为"=I3",但G3单元格设置为特殊类型的中文大写数字.
请问怎样才能从G3中读数据时,直接就取到中文大写数字,也就是壹拾贰点叁肆,而不是12.34
...全文
7 点赞 收藏 5
写回复
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
painAndhappy 2003-07-16
感谢
lihonggen0(李洪根,用.NET,标准答案来了)
想再问一下
除了用编码实现之外,能不能直接调用某个方法或属性取得呢?
回复
lihonggen0 2003-07-16
'*********************************************************
'* 名称:nNumber2Chinese
'* 功能:数值转换为人民币(汉字)
'* 用法:nNumber2Chinese(数值)
'*********************************************************
Public Function Num2Chi(txtJE As Double) As String
Dim I, K As Integer
Dim NC, nd, ka, chrNum, strZheng As String
Dim c1, c2, c3 As String
Dim K1 As Integer
Dim Zheng As String
Dim Xiao As String
NC = Trim(Format(txtJE, "##0.00"))
c1 = "仟佰拾万仟佰拾亿仟佰拾万仟佰拾元"
c2 = "角分"
c3 = "玖捌柒陆伍肆叁贰壹"
If NC = 0 Then
Num2Chi = "零元整"
Exit Function
End If
Num2Chi = ""
Zheng = Mid(NC, 1, (Len(NC) - 3))
Xiao = Mid(NC, (Len(Zheng) + 2))
If Val(Xiao) <> 0 Then
For I = Len(Xiao) To 1 Step -1
chrNum = Mid(Xiao, I, 1)
If chrNum <> 0 Then
Num2Chi = Mid(c2, I, 1) & Num2Chi
Num2Chi = Mid(c3, (Len(c3) - chrNum + 1), 1) & Num2Chi
End If
Next I
End If

K = 0
If Val(Zheng) <> 0 Then
Num2Chi = "元" & Num2Chi
For I = Len(Zheng) To 1 Step -1
If (Len(Zheng) - I) = 4 Then
Num2Chi = "万" & Num2Chi
ElseIf (Len(Zheng) - I) = 8 Then
Num2Chi = "亿" & Num2Chi
ElseIf (Len(Zheng) - I) = 12 Then
Num2Chi = "万" & Num2Chi
End If
chrNum = Mid(Zheng, I, 1)
If chrNum <> 0 Then
If I = Len(Zheng) Then
Num2Chi = Mid(c3, (Len(c3) - chrNum + 1), 1) & Num2Chi
Else
If (Len(Zheng) - I) <> 4 And (Len(Zheng) - I) <> 8 And (Len(Zheng) - I) <> 12 Then
Num2Chi = Mid(c1, (Len(c1) - K), 1) & Num2Chi
End If
Num2Chi = Mid(c3, (Len(c3) - chrNum + 1), 1) & Num2Chi
End If
Else
If Mid(Num2Chi, 1, 1) <> "元" And Mid(Num2Chi, 1, 1) <> "万" And Mid(Num2Chi, 1, 1) <> "亿" Then
If Mid(Num2Chi, 1, 1) <> "零" Then
Num2Chi = "零" & Num2Chi
End If
End If
End If
K = K + 1
Next I
End If
If Right(Trim(Num2Chi), 1) <> "分" Then
Num2Chi = Num2Chi & "整"
End If
End Function
回复
painAndhappy 2003-07-16
没人回答吗?
急啊!
回复
painAndhappy 2003-07-16
试了一下,好像是Text属性
谢谢两位!
回复
AechoJohn 2003-07-16
用单元格(或Range对象)的Value属性
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7451

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告