【发布时间】:2016-04-09 18:53:04
【问题描述】:
Module Module1
Sub main()
Dim pl(), pll() As Integer
Dim a, b As Integer
ReDim pl(0)
ReDim pll(0)
Do
a = InputBox("insert number:")
If a <> 0 Then
b = b + 1
ReDim Preserve pl(b)
pl(b) = a
End If
Loop Until a = 0
pll = **se(pl)**
End Sub
Function se(pol()) As Integer()
Dim r, t, w, m As Integer
Dim fix() As Integer
ReDim fix(0)
r = UBound(pol)
w = 2
For t = 1 To r
For m = 1 To r
If w <= r Then
If pol(w) < pol(t) Then
ReDim Preserve fix(t)
fix(t) = pol(w)
End If
End If
w = w + 1
Next
Next
se = fix
End Function
结束模块
嗨,我创建了这个函数(不知道它是否工作)se(pl),它接受数字数组并返回该数组,但按升序排列。但是当我想将该函数分配给数组时 - pll=se(pl) 它给了我这个错误==>“整数类型的值不能转换为对象,因为整数不是引用类型”
对不起,我是菜鸟,有人可以帮忙吗?
【问题讨论】:
标签: arrays vba visual-studio function