pratikshahse
asked on
put " ' " in front of each number Asp.net (vb)
I have a string
string = 0000000,1111111,2222222,33 33333
I want to put " ' " in front of each number so the string should look like
string = '0000000','1111111','22222 22','33333 33'
each number in the string is 7 digits long.
How do i do this.
Thanks
string = 0000000,1111111,2222222,33
I want to put " ' " in front of each number so the string should look like
string = '0000000','1111111','22222
each number in the string is 7 digits long.
How do i do this.
Thanks
stringName = "'" & stringName.Replace(",", "'.'") & "'"
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
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
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,3 333333"
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
strOld = "0000000,1111111,2222222,3
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.