Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

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

Posted on 2006-11-16
Medium Priority
250 Views
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
0
Question by:pratikshahse
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 35

Expert Comment

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

LVL 35

Expert Comment

ID: 17962519
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

LVL 8

Expert Comment

ID: 17963745
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

LVL 5

Accepted Solution

kumar_jac earned 1000 total points
ID: 17964781

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

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
###### Suggested Courses
Course of the Month4 days, 10 hours left to enroll