I need to pass an array to a function.
However, sometimes I don't want that to happen.
In other words, I need to write a function that should look at the input array to see if it exists, do something, and if it doesn't exist, do other things.
Currently, I have written something like this:
But, that doesn't work.
It gives me a compile error (doesn't compile)
I am not sure if the concept of Null that I am using is the right concept to use in this case or not, and if not, then how to do what I am trying to do.
Please help.
Thanks.
However, sometimes I don't want that to happen.
In other words, I need to write a function that should look at the input array to see if it exists, do something, and if it doesn't exist, do other things.
Currently, I have written something like this:
Code:
Private Sub Command15_Click()
Dim XArray() As String
Dim N As Long
N = proc1_Command15("abc", Null)
End Sub
Code:
Private Function proc1_Command15(ByRef XVal As String, ByRef XArray() As String) As Long
Dim L As Long
Dim s As String
If IsNull(XArray()) Then
s = "XArray is null. Nothing added!"
Else
L = Array_Length(XArray())
ReDim Preserve XArray(L) As String
XArray(L) = XVal
s = "XVal added." & vbCrLf & vbCrLf & "Number of records:" & vbTab & (L + 1)
End If
MsgBox s
End Function
It gives me a compile error (doesn't compile)
I am not sure if the concept of Null that I am using is the right concept to use in this case or not, and if not, then how to do what I am trying to do.
Please help.
Thanks.