方法一:
Private Sub Command1_Click()
Dim xlapp As Object, n As Currency, temp As String
Set xlapp = CreateObject("Excel.Application")
Randomize
n = Int(Rnd * 10 ^ 15)
temp = n
temp = temp & vbCrLf & xlapp.Evaluate("NUMBERSTRING(" & n & ", 1)")
temp = temp & vbCrLf & xlapp.Evaluate("NUMBERSTRING(" & n & ", 2)")
temp = temp & vbCrLf & xlapp.Evaluate("NUMBERSTRING(" & n & ", 3)")
Set xlapp = Nothing
MsgBox temp
End Sub
方法二:
Private Sub Command1_Click()
Dim xlapp As Object, n As Currency, temp As String
Set xlapp = CreateObject("Excel.Application")
Randomize
n = Int(Rnd * 10 ^ 12)
temp = n
temp = temp & vbCrLf & xlapp.Evaluate("text(" & n & ",""[dbnum1]"")")
temp = temp & vbCrLf & xlapp.Evaluate("text(" & n & ",""[dbnum2]"")")
temp = temp & vbCrLf & xlapp.Evaluate("text(" & n & ",""0[dbnum1]"")")
Set xlapp = Nothing
MsgBox temp
End Sub
本文介绍两种使用VBA调用Excel应用程序的方法,将随机生成的大额数字转换成中文大写形式,涉及Excel的不同函数应用。
1299

被折叠的 条评论
为什么被折叠?



