is there a way to split a string into an array based off so many bytes instead of a delimeter?
Dim NewString$, I&
Const AmountOfBytes& = 2
Const TestString$ = "this is a test!"
For I = 1 To Len(TestString) Step AmountOfBytes
NewString = Mid$(TestString, I, AmountOfBytes)
Debug.Print NewString
Next I
Quote from: Imperceptus on May 15, 2005, 09:20 PM
is there a way to split a string into an array based off so many bytes instead of a delimeter?
It's the same thing.
Dim aNew As String()
aNew = Split("AAA123BBB123CCC123DDD", "123")
MsgBox aNew(2) 'shows "CCC"
No it's not the same thing :/ That just splits it by "123", this is what he wants:
Public Sub SplitByts(ByVal ToSplit As String, ByVal SplitBy As Integer, ByRef strOut() As String)
Dim dblSize As Double
dblSize = Len(ToSplit) / SplitBy
If InStr(dblSize, ".") Then dblSize = (dblSize \ 1) + 1
ReDim strOut(0 To dblSize - 1)
For x = x To dblSize - 1
strOut(x) = Mid(ToSplit, (x * SplitBy) + 1, SplitBy)
Next x
End Sub
It finds how big the array should be, then fills it, simple as that. The only thing that's wrong with UL's code is that it dosent add tot eh array. It splits it up fine.
~-~(HDX)~-~
Oh, oops, into an array. Oh well, should be simple enough to modify my code to work with it..
Thanks for all your suggestions
Text1.Text = "123ABC"
Text2.text = " "
Do you mean like:
Text2.Text = Split(Text1.Text, "A")(1)
-- Then
Text2.Text = "BC"
?