split? left? right?

i got rs("x") with lots of numbers divided with comma(,)
*ends with comma too
3434,4343,5456,676556565,65,

how i can print them with space between them?
like this:(and to kill the last comma)
3434 ,4343 ,5456 ,676556565 ,65 ,
sasha85Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

samic400Commented:
dim mArray
mArray =  Split(rs("x"), ",")

for i=0 to uBound(mArray)
    response.write mArray(i) & " "
next


0
Mass Dot NetCommented:
Give this a shot.
<%
Dim strValues, arrValues, iNumberCount, iIndex, sValue
 
'// If the entire string is NULL, convert it to an empty string.
strValues = Trim(rs("x") & "")
 
'// Convert the string into an array of numbers.
arrValues = Split(strValues, ",")
 
iNumberCount = 0
For iIndex = 0 to UBound(arrValues)
	'// Get an individual item in the array, and shave off extra spaces on either side.
	sValue = Trim(arrValues(iIndex))
	
	'// If the value is a number, go ahead and write it out.
	If IsNumeric(sValue) Then
		iNumberCount = iNumberCount + 1
		If (iNumberCount > 1) Then Call Response.Write(", ")
		Call Response.Write(sValue)
	End If
Next
%>

Open in new window

0
sasha85Author Commented:
deathtospam ,i understand samic400 solution...
i am kind of lost with yours:

strValues = Trim(rs("x") & "") ?
      sValue = Trim(arrValues(iIndex)) ?
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

hieloCommented:
Comma to the left: 3434, 4343, 5456, 676556565, 65
Response.Write Replace( Left( rs("x"),Len(rs("x"))-1 ), ",", ", ")

Comma to the right: 3434 ,4343 ,5456 ,676556565 ,65
Response.Write Replace( Left( rs("x"),Len(rs("x"))-1 ), ",", " ,")
0
sasha85Author Commented:
well that's what i'm talking about...replace function is great!:)
hielo, how are you?:)
i understand deathtospam's code now but,
what do you think about deathtospam's code?
i mean what is better-to replace from the begining or processing the rs("x") as deathtospam did...
0
hieloCommented:
>>...replace function is great!:)
It sure is

>>hielo, how are you?:)
Super

>>what is better-to replace from the begining or processing the rs("x") as deathtospam did
I find the "Replace" option easier to understand/maintain. If the rs("x") values is "consistent" , processing the other way is kind of an overkill, espcially since it saves the value of Split every time it is called. The way I see it, don't consume extra memory resources if it is not needed.
0
sasha85Author Commented:
Replace( Left( rs("x"),Len(rs("x"))-1 ), ",", " ,")
runs on the all rs("x")
or i still need to split and replace every part?
0
hieloCommented:
>>or i still need to split and replace every part?
No Splitting necessary. I am assuming rs("x") is some db field. As an example, you would use it as follows:

'assuming you queried the db and the result is in rs
while Not rs.eof
 Response.Write Replace( Left( rs("x"),Len(rs("x"))-1 ), ",", " ,")
rs.moveNext
wend
0
sasha85Author Commented:
i just tried that...i got plain page...
my rs("x") was 232,343445,565656,35324,2432,
0
hieloCommented:
>>i got plain page
You must be doing something else wrong. I tested that input and it worked fine for me.
<html>
<head>test.html</head>
<body>
<h1>Test throught IE</h1>
<script type="text/vbscript">
Dim rs,result
rs="3434,4343,5456,676556565,65,"
result = Replace( Left( rs,Len(rs)-1 ), ",", ", ")
document.write result
</script>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sasha85Author Commented:
aa ok...my mistake...

thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.