Link to home
Start Free TrialLog in
Avatar of pratikshahse
pratikshahse

asked on

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
Avatar of Raynard7
Raynard7

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
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
ASKER CERTIFIED SOLUTION
Avatar of kumar_jac
kumar_jac
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial