This is the code i work out:
When i use the last MessageBox to display all value inside the array (strConcatenatted), i found that the array are all empty except the last array, which has value on it.Code:Private Function funSplitText(ByVal strRinggit As String) As String() Dim strSplitted() As String = System.Text.RegularExpressions.Regex.Split(strRinggit, " ") Dim strConcatenatted() As String Dim strConcatenattedSize As Integer = 0 ReDim strConcatenatted(strConcatenattedSize) Dim strTemp1 As String Dim strTemp2 As String Dim intCounter As Integer For intCounter = 0 To strSplitted.GetUpperBound(0) strTemp1 = strTemp1 & String.Concat(" ", strSplitted(intCounter), " ") strTemp1 = strTemp1.TrimStart(" ") strTemp1 = strTemp1.TrimEnd(" ") strTemp2 = strSplitted(intCounter) If strTemp1.Length > 39 Then strConcatenattedSize += 1 ReDim strConcatenatted(strConcatenattedSize) strConcatenatted(strConcatenattedSize) = strTemp2 strTemp1 = strTemp2 Else strConcatenatted(strConcatenattedSize) = strTemp1 End If 'MessageBox.Show(strConcatenattedSize & ": " & strConcatenatted(strConcatenattedSize)) Next Dim x As Integer For x = 0 To strConcatenatted.GetUpperBound(0) MessageBox.Show(x & ": " & strConcatenatted(x)) Next Return strConcatenatted End Function
For example, strConcatenatted's length is 3
the value on:
strConcatenatted(0) is ""
strConcatenatted(1) is ""
strConcatenatted(2) is "abcde"
actually all of them should has string value.
why is this so weird? pls guide me, thank you.




Reply With Quote