String.join help

Hi!

I need some help with string.join
presently i have two numerical values
amount 1 - 10
amount 2 - 20

i am trying to combine the two into one string as ‘1020’

However, I keep getting only ‘20’ when i attempt to use string join

This is the formula i have been using:

Thank you!

I think, here you have no need to use string.join.
try as amount1 +“”+ amount2.

string.join has different arguments which we need to supply correctly.

2 Likes

hello @avene
You can try:
String.Concat(amount1,amount2) to get your desired result.
String.Join method is used to concatenate the elements of an array, using the specified separator between each element.
hence the parameters passed in the method are different.
And the purpose of this method is also different.

9 Likes

String.Join acts only on an array or List.

Example

Dim array(2) As String
array(0) = “Dog”
array(1) = “Cat”
array(2) = “Python”

’ Join array.
Dim result As String = String.Join(“,”, array)

OUTPUT

Dog,Cat,Python

To combine strings you can use + or & .
Because the + symbol also represents an arithmetic operator, your code will be easier to read if you use the & symbol for concatenation.

amount1.ToString() & amount2.ToString()
amount1.ToString() + amount2.ToString()

or you can use,

String.Concat(amount1, amount2)

Thanks,
Rupesh

12 Likes