在VBA里总会有dim mat 这个mat是什么意思 谢谢大家!

比如FunctionSampleCovariance(Rng_Name1AsString,Rng_Name2AsString)AsDouble'Tocallthisfun... 比如
FunctionSampleCovariance(Rng_Name1 As String, Rng_Name2 As String) As Double

'To call this function, in the spreadshhet type:=SampleCovariance("RangeName1","RangeName1") and then pressthe Enter key.

Dim Rng1 As Range, Rng2 As Range
Dim i As Integer, j As Integer
Dim db As Double, db1 As Double, db2 AsDouble
Dim mat1(), mat2()

Set Rng1 = Range(Rng_Name1)
Set Rng2 = Range(Rng_Name2)

mat1 = Rng1
mat2 = Rng2

If UBound(mat1, 1) <> UBound(mat2, 1)Then
MsgBox "In SampleCovariance,number of rows included in the two inputted named ranges are not thesame.", , "Error Message"
End If

If UBound(mat1, 2) <> UBound(mat2, 2)Then
MsgBox "In SampleCovariance,number of columns included in the two inputted named ranges are not thesame.", , "Error Message"
End If

db1 = SampleMean(Rng_Name1)
db2 = SampleMean(Rng_Name2)

db = 0
For i = 1 To UBound(mat1, 1)
For j = 1 To UBound(mat1, 2)
db = db + (mat1(i, j) - db1) *(mat2(i, j) - db2)
Next j
Next i

SampleCovariance = db / (UBound(mat1, 1) *UBound(mat1, 2) - 1)

EndFunction
展开
 我来答
仙剑4之处
2014-05-20 · TA获得超过397个赞
知道小有建树答主
回答量:1269
采纳率:25%
帮助的人:230万
展开全部
dim 后面的是变量
你也可以改成fat,没差
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式