According to the wiki documentation…“The required parameter, string, is a valid string expression; if string is a zero-length string (""), Split returns an empty array.” This doesn’t seem to be the case! See sample Basic Code below. If you un-comment the Line where the Split function is being called, you will notice that the UBound Function no loger returns -1 (and the DataSet.length will be 1 insead of 0). In Fact, what is returned is an array containing an empty string. eg. DataSet; which is not the same as an empty array.
This issue has resulted many hours of debugging some code where I was using the result of the UBound function in a For… Next loop; as in the example below.
Hope this helps anyone else who has been using the Split and UBound functions together; as I have.
Dim DataString = "" Dim Delim = "," Dim DataSetCount Dim DataSet Dim i DataSet = Array() //DataSet = Split(DataString, Delim) DataSetCount = UBound(DataSet) If DataSet = "" Then Print "Empty DataSet" Print "DataSet.Length = " & DataSet.length & vbCRLF & "UBound(DataSet) = " & DataSetCount For i = 0 To DataSetCount Print "This message should NEVER be displayed" Next