omit comma at end of looping data

meldraper
meldraper used Ask the Experts™
on
Hello, i have a do loop where i am listing dates separated by a comma but i don't want the comma after the last date listed.  How do i get around that?  Thanks in advance.
if not p.eof then
do while not p.eof
schedule=formatdatetime(p("pdsdate"),1) & ", "
p.movenext
loop
end if

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You could simply remove it at the end:

schedule = ''
if not p.eof then
do while not p.eof
schedule=schedule & formatdatetime(p("pdsdate"),1) & ", "
p.movenext
loop
end if
lngPos = Instr(", ", schedule)
if lngPos > 0 then
lngLen = Len(schedule) - 2
schedule = Right$(schedule, lngLen)
end if

Author

Commented:
you got me on the right track, but i used left instead of right and it worked.  Thank you.


schedule=Left(schedule,Len(schedule)-2)
Oops.  My mistake.  Been a long day...

Author

Commented:
No big deal, made me think.  Thank you so much.  It HAS been a long day and HOT in Texas.
HA!  I don't envy you.  I'm in San Diego and I feel like it's sweltering at 79 degrees.

Thank you for the points.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial