I have a long string like this
dim LongString as String = \"123abc456def789ghi\"
And I want to split it into a string array. Each element
I have added some more logic to @jon code. This will work perfectly for the string which has length less than length passed.
Public Shared Function SplitByLength(ByVal [text] As String, ByVal length As Integer) As String()
Dim stringLength = text.Length
Dim arrLength As Integer = ([text].Length \ length) - 1 + IIf(([text].Length
Mod length) > 0, 1, 0)
Dim strArray As String() = New String(arrLength) {}
Dim returnString As String = ""
Dim i As Integer
Dim remLength As Integer = 0
For i = 0 To strArray.Length - 1
remLength = stringLength - i * length
If remLength < length Then
strArray(i) = [text].Substring((i * length), remLength)
Else
strArray(i) = [text].Substring((i * length), length)
End If
Next i
Return strArray
END FUNCTION