Sample usage:Code:Public Function StringArray(ParamArray Strings() As Variant) As String() Static strTemp() As String Dim lngUB As Long, lngA As Long lngUB = UBound(Strings) If lngUB > -1 Then ReDim Preserve strTemp(lngUB) For lngA = 0 To lngUB strTemp(lngA) = CStr(Strings(lngA)) Next lngA StringArray = strTemp Else StringArray = Split(vbNullString) End If End FunctionNotes:Code:Private Sub Form_Load() MsgBox Join(StringArray("Test", "Really."), " this thing. ") End Sub
The function always returns an existing array. UBound may be -1 if there are no items in the array.
This function doesn't have error detection, this means you could pass objects, controls etc. into the function, which would result into an error message (instead of the function silently handling the error and resulting into a null string).
(I actually found it interesting that I didn't find even an attempt to create this function anywhere on this forum.)




Reply With Quote