调用EXCEL 实现阿拉伯数字转中文

方法一:

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

你可能感兴趣的:(Excel)