Valhalla Legends Forums Archive | Visual Basic Programming | Split

AuthorMessageTime
Imperceptus
is there a way to split a string into an array based off so many bytes instead of a delimeter?
May 16, 2005, 2:20 AM
UserLoser.
[code]
    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
[/code]
May 16, 2005, 3:18 AM
Grok
[quote author=Imperceptus link=topic=11602.msg112606#msg112606 date=1116210004]
is there a way to split a string into an array based off so many bytes instead of a delimeter?
[/quote]

It's the same thing.

[code]
    Dim aNew As String()
    aNew = Split("AAA123BBB123CCC123DDD", "123")
    MsgBox aNew(2)          'shows "CCC"
[/code]
May 16, 2005, 5:40 PM
HdxBmx27
No it's not the same thing :/ That just splits it by "123", this is what he wants:
[code]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[/code]
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)~-~
May 16, 2005, 6:18 PM
UserLoser.
Oh, oops, into an array.  Oh well, should be simple enough to modify my code to work with it..
May 16, 2005, 6:47 PM
Imperceptus
Thanks for all your suggestions
May 21, 2005, 6:54 PM
iNsaNe
Text1.Text = "123ABC"
Text2.text = " "

Do you mean like:

Text2.Text = Split(Text1.Text, "A")(1)

-- Then

Text2.Text = "BC"

?
March 5, 2006, 10:57 PM

Search