函数返回多个值的问题
各位老师:
请教一下如何实现一个函数返回多个值的问题,如下.我要同时返回a,b的值,如何实现?谢谢
Public Function ReturnMultiValue() As String
a = 1
b = 2
ReturnMultiValue = a
End Function
[解决办法]
改成以下:
Option Explicit
Private Sub Command1_Click()
Dim x As Integer, y As Integer
Print ReturnMultiValue(x, y), x, y
End Sub
Public Function ReturnMultiValue(ByRef x As Integer, ByRef y As Integer) As Integer
Dim a As Integer, b As Integer
a = 1
b = 2
x = a
y = b
ReturnMultiValue = a
End Function
[解决办法]
也可以
Private Type mType
a As String
b As Integer
End Type
Private Function GetmType() As mType
Dim test As mType
test.a = "AA "
test.b = 123
GetmType = test
End Function