• Welcome to Valhalla Legends Archive.
 

Split

Started by Imperceptus, May 15, 2005, 09:20 PM

Previous topic - Next topic

Imperceptus

is there a way to split a string into an array based off so many bytes instead of a delimeter?
Quote from: Hazard on August 07, 2003, 03:15 PM
Highlight your entire code. Press the delete key. Start over again using Cuphead's CSB tutorial and work your way from their rather than raping code from downloaded sources meant purely for learning purposes. If this does not fix the problem, uninstall Visual Basic and get a new hobby. I suggest Cricket.

UserLoser.

#1

    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

Grok

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"

Hdx

#3
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)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

UserLoser.

Oh, oops, into an array.  Oh well, should be simple enough to modify my code to work with it..

Imperceptus

Thanks for all your suggestions
Quote from: Hazard on August 07, 2003, 03:15 PM
Highlight your entire code. Press the delete key. Start over again using Cuphead's CSB tutorial and work your way from their rather than raping code from downloaded sources meant purely for learning purposes. If this does not fix the problem, uninstall Visual Basic and get a new hobby. I suggest Cricket.

iNsaNe

Text1.Text = "123ABC"
Text2.text = " "

Do you mean like:

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

-- Then

Text2.Text = "BC"

?