DarkXylese
DarkXylese

Reputation: 3

Splitting a string in vb.net (no delimiters)

First time making a game, and I'm loading in the map form an xml file. Each row is literally a row that comes up on the screen.

Example string: 0000010020111030010000002130000101000... I need something to split each of those numbers into an array - so that one number is one item in the array; to be able to print the map.

I tried using this but I quickly figured out that I need delimiters "," and such.

    Dim t() As String 'temp array
    Dim wordl1aXtemp As String 'the very long string of numbers
    For j = 0 To 1
        For i = 0 To 41
            wordl1aXtemp = wordl1aX(j, i)
            t = wordl1aXtemp.Split("") 'temp array loaded
        Next
        j += 1
    Next

I already have the map designed, and its going to be a pain going back to put a thousand or so ",".

How can I break up a long chain of numbers into an array where each character is 1 item.

Upvotes: 0

Views: 1376

Answers (2)

Mister Henson
Mister Henson

Reputation: 505

Are you sure that you can't just use the string itself? https://msdn.microsoft.com/de-de/library/microsoft.visualbasic.strings.getchar(v=vs.110).aspx

(Basically a string is just an array of characters)

Upvotes: 0

TheValyreanGroup
TheValyreanGroup

Reputation: 3599

You want string.char(). A string is nothing more than an array of characters. You can access each character of the string by calling the char method with a specific index.

 Dim test As String = "Today"
 x = test.char(3) 'Will give you "a"

Upvotes: 2

Related Questions