# put " ' " in front of each number Asp.net (vb)

I have a string

string = 0000000,1111111,2222222,3333333

I want to put " ' " in front of each number so the string should look like

string = '0000000','1111111','2222222','3333333'

each number in the string is 7 digits long.

How do i do this.

Thanks
###### Who is Participating?

Commented:

Hi,
You can achive this in ONE line as follows.

just copy and paste this

string a = "0000000,1111111,2222222,3333333"

a = "'" + a.replace("," ,"','")   + "'"

0

Commented:
stringName = "'" & stringName.Replace(",", "'.'") & "'"
0

Commented:
sorry typeo

stringName = "'" & stringName.Replace(",", "','") & "'"

so if you replace the comma with a ',' it will do everything except for the start and finish - so you can then put in a single inverted comma
0

Commented:
Here is a script that is one better.... It'll add the ' at the beginning and end of the string, as well as around the ,

strOld = "0000000,1111111,2222222,3333333"
arrString = Split(strOld, ",")
For i=0 to UBound(arrString)
if i= 0 then
strNew = "'" & arrString(i) & "','"
elseif i = UBound(arrString) then
strNew = strNew & arrString(i) & "'"
else
strNew = strNew & arrString(i) & "','"
end if
Next

msgbox strNew
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.