Splitting A String In Two Parts(REALBASIC)

1.5k Views Asked by At

I am trying to split a string at the character ":" but cant create two separate strings from the split. If somebody could help me, I would appreciate it.

3

There are 3 best solutions below

0
On

Actually, the code is incorrect. It should be:

Dim s() As String = Split("Zero:One:Two", ":")

If you don't pass in the delimiter it assumes a space which wouldn't work in this case.

The online docs are at http://docs.realsoftware.com/index.php/Split

0
On

Split is best for actually splitting the text, but you can also use the string-manipulation methods: Left, Right, Mid and InStr.

1
On

In RealBasic, the Split method doesn't create two (or more) separate strings but rather a single string array.

Dim s() As String = Split("Zero:One:Two", ":")
's() now contains the substrings like so:
's(0) = "Zero"
's(1) = "One"
's(2) = "Two"