how to chopp off two final comma

L

Lim Heng Sin

I have one-dimensional array, myArray. Let said it
contains England, China, Japan. I want it to display in
this way:

England,China,Japan

So, i used the code as follow:

For nIndex = LBound(myArray) to UBound(myArray)

str = str + Trim(myArray(nIndex)) + "'"

Next

But this will return something like that:

England,China,Japan,,

Is there any way to take off the final two commas using
VBA code? What is the function.
 
E

Ed Terlouw

Lim, tf there are always 2 comma's you can try something like this

str = Left(str,len(str)-2)

HTH
Ed
 
L

Lim Heng Sin

-----Original Message-----
Lim, tf there are always 2 comma's you can try something like this

str = Left(str,len(str)-2)

HTH
Ed





.
Thanks, it's working
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top