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

Medium Priority
273 Views
Last Modified: 2010-05-03
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

 

Thanks a lot in advance
Comment
Watch Question

 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.

Ask the Experts
Head of Software Services
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

Author

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 your great and quick answer.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

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

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.