We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

# Problem concatenating a string

on
Medium Priority
273 Views
what i need to do is that when I loop through a recordset i get some ids.
These Ids are in a lump (Start and end)

For each lump(eg numberC_Start and numberC_END )I need to get all the number from start to end
and concatanate it in a string .

How can I do it?

Code:
dim numberA_Start as long
dim numberB_Start as long
dim numberC_Start as long

dim numberA_END as long
dim numberB_END as long
dim numberC_END as long

numberA_Start =5
numberA_END =5

numberB_Start =66
numberB_END =69

numberC_Start =91
numberC_END =95

dim strResult as string

strResult=5/66/67/68/69/91/92/93/94/95/

EG of a loop

Dim tempFirstNumber as long,tempLastNumber as long,tempStrResult as string
dim rs as adodb.Recorset,Delimiter as string

set Delimiter="/"
set rs=GetStuff......

do while not rs.eof
tempFirstNumber =rs.fields("FirstNum").value
tempLastNumber =rs.fields("LastNum").value
'HELP
'//calcuLate all the numbers within first and last and concatanate in a string

rs.movenext
loop
tempStrResult

Comment
Watch Question

## View Solutions Only

Commented:
do while not rs.eof
tempFirstNumber =rs.fields("FirstNum").value
tempLastNumber =rs.fields("LastNum").value
'HELP
'//calcuLate all the numbers within first and last and concatanate in a string
for i = tempfirsnumber to templastnumber
mySTring = mystring & cstr(i) & "/"
next 'i

rs.movenext
loop
tempStrResult

is that what you're looking for?

Not the solution you were looking for? Getting a personalized solution is easy.

Commented:
Hi Gabriel_Brienza,

set Delimiter="/"
set rs=GetStuff......

do while not rs.eof
tempFirstNumber =rs.fields("FirstNum").value
tempLastNumber =rs.fields("LastNum").value
'HELP
For i = tempFirstNumber To tempLastNumber
strTheNumbers = strTheNumbers & Cstr(i) & Delimiter
Next
strTheNumbers = Left(strTheNumbers,Len(strTheNumbers)-1) 'trims off the trailing delimiter

rs.movenext
loop
tempStrResult

Tim Cottee

Commented:
thanks guys
that both worked and I didnt know who to assign the answer to.I decide to split .
Hope its fair

##### Thanks for using Experts Exchange.

• View three pieces of content (articles, solutions, posts, and videos)
• Ask the experts questions (counted toward content limit)
• Customize your dashboard and profile