帮忙看看这个错误?
编译错误:
类型不匹配 或缺少用户定义类型
XYMult是多项式相乘函数.array(1,2,3)表示x^2+2*x+3
-------------------------
Private Sub Command1_Click()
Dim x(), y() As Integer
Dim res_arr() As Integer
Dim tempstr As String
ReDim x(1)
x(0) = 1
x(1) = 2
ReDim x(1)
y(0) = 3
y(1) = 11
ReDim res_arr(2)
res_arr = XYMult(x, y)
For i = 0 To 2
tempstr = tempstr & res_arr(i) & " "
Next
MsgBox tempstr
End Sub
Public Function XYMult(x() As Integer, y() As Integer) As Integer() '多项式相乘
Dim temp As Integer
Dim res() As Integer
n = UBound(x()) - LBound(x()) '第一个多项式的次数
m = UBound(y()) - LBound(y()) '第二个多项式的次数
ReDim res(n + m) ''定义乘积多项式的项数
For i = 0 To n + m
res(i) = 0 ''给乘积多项式赋初值0
Next
For i = 0 To n + m ''主要算法
temp = 0
For j = 0 To n
If i - j >= 0 And i - j <= m Then
temp = temp + x(j) * y(i - j)
End If
Next j
res(i) = temp
Next i
XYMult = res
End Function