日语玩游戏:大家帮我看一下 错在哪里?

来源:百度文库 编辑:高校问答 时间:2024/05/02 01:28:36
我从网上下载了一段自定义函数的代码放到我的程序中VFP,
为什么老是提示出错.
Function RMB_DX(money As Variant)
Dim m1 As Long, n1 As Long, n2 As Integer, n3

As Integer
m1 = Application.WorksheetFunction.Round(money

* 100, 0)
n1 = Int(m1 / 100)
n2 = Int(m1 / 10) - n1 * 10
n3 = m1 - n1 * 100 - n2 * 10
If n3 = 0 Then
RMB_DX = "整"
Else
RMB_DX = Application.WorksheetFunction.Text(n3,

"[DBnum2]") & "分"
End If
If n2 = 0 Then
If n1 <> 0 And n3 <> 0 Then RMB_DX = "零" &

RMB_DX
Else
RMB_DX = Application.WorksheetFunction.Text(n2,

"[DBnum2]") & "角" & RMB_DX
End If
If n1 <> 0 Or m1 = 0 Then
RMB_DX = Application.WorksheetFunction.Text(n1,

"[DBnum2]") & "元" & RMB_DX
End If
End Function

运行到第二行之后提示错误不能识别的命令谓词
是不是这代码不能用在VFP上呢
用在VB上能行吗?

VFP中没有Dim关键字,Dim在VB中是定义过程级和模块级变量才用的。因此VFP自然不能识别Dim行的语句了。

这段代码单纯用在VB上也是不可以的,它至少引用了Application.WorksheetFunction等对象,Application.WorksheetFunction是EXCEL中的对象,要想在VB中使用,必须引用EXCEL库并对Application.WorksheetFunction等对象进行实例化才行。

分析代码,这个函数的功能应该是在EXCEL中实现将小写金额向大写中文金额的转换,应该是VBA,如果这样的话,在EXCEL中编程运行是没问题的。