How to go directly "ToString" from array?


In the code below, there is a populated array of type string. Because there are some " marks that I am not sure really exist or not, I want to remove them by converting the array into a string. However, it appears that the only option is ToText.

Two questions:

  1. Whats the diff between string and text?
  2. Is there a way to do this without having to dimension a new variable?

Thank you,

Dim tmpToNo() As String
Dim tToNo As String
tToNo  = tmpToNo(1)  //  This gives the TO Number

Dim Num As integer = tToNo.ToInteger
tToNo = num.ToString

Text is deprecated. Use String instead. Where are you seeing “ToText”?

Since your array is already of type String, why is there a need for any kind of conversion?

ToInteger will fail in the presence of a " character anyway.

What are you actually trying to do?

Don’t quite understand what the issue is, but @Tim_Hare is spot on, don’t use Text anymore.

If you want to guarantee an integer value as a string from your array without an intermediate variable you could try:

tToNo = Integer(tToNo.ToInteger).ToString

Something like?

Dim tmpToNo() As String
Dim tToNo As String
tToNo  = tmpToNo(1).ToInteger.ToString

but I don’t understand this:

How converting the array into a string removes some " marks?


where do you see the ToText as the only option?

What Xojo version are you using?

Hello and thank you for your responses.

What I have in the variable is “1”. I want to remove the quotes. I guess this is a backwards way of doing it! Better solution?

Using 2023 R4.
The only option that comes up is .ToText which is shown by the IDE.

@TimH - To Integer does not fail. But it is funky to say the least!


Are those regular quotes or curly quotes? (the forum usually change regular to curly)

You want something like this?

Var startString As String = """1"""
Var finalString As String = startString.ReplaceAll("""","")


They are regular quotes.

There’s no quickie answer to this - you’re just going to have to loop through the elements of the array and use ReplaceAll to remove the offending characters.

@Alberto -
You sample code worked perfectly. My question is, why does it need 4 quotes on the left and two on the right?


Four quotes = a double quote character. Two quotes = empty string. " “” " is Xojo’s way to express a double quote character with a space before and a space after.

Thank you Eric!

I appreciate the explanation.

So maybe this?

Var startString() As String 

For i As Integer = startString.FirstIndex To startString.LastIndex
  startString(i) = startString(i).ReplaceAll("""","")

2 quotes are for the string, let’s call them left and right quote or string endings, so if you only use 2 then is empty. To add a quote to a string we need a way to make it different, so a single quote within the string limits (left/right quote) needs to be doubled, so basically """" means:

  • first quote the start of the string code
  • last quote the end of the string code
  • second/third quote, add a single quote to the string

Are you not looking for:

dim s as string = String.FromArray(tmpToNo, separator)


You need to loop trough all string array items and aad them to an integer array with item.ToInteger
Or Integer.Parse(item)

Or use a variant array to begin with, so that you’l not have the issue in the first place.