Public Function arrayfunction(i As Integer) As Integer()
Dim x(2) As Integer
x(0) = i + 10
x(1) = i + 20
arrayfunction = x '把x賦值給函式arrayfunction
End Function
Private Sub Command1_Click()
Dim y(2) As Integer
y = arrayfunction(1)
MsgBox y(0)
MsgBox y(1)
End Sub
編譯錯誤,不能賦值給陣列,為什么啊,求解,幫忙解答者,重賞40分
uj5u.com熱心網友回復:
把 Dim y(2) As Integer 改成 Dim y() As Integeruj5u.com熱心網友回復:
Option Explicit
Public Function arrayfunction(i As Integer) As Integer()
Dim X() As Integer
ReDim X(1)
X(0) = i + 10
X(1) = i + 20
arrayfunction = X '把x賦值給函式arrayfunction
End Function
Private Sub Command1_Click()
Dim Y() As Integer
ReDim Y(UBound(arrayfunction(1)))
Y = arrayfunction(1)
MsgBox Y(0)
MsgBox Y(1)
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/132483.html
標籤:VB基礎類
上一篇:使用VBA決議HTML檔案
下一篇:vba來實作6+1不重合排列組合
