[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Problem concatenating a string

Posted on 2006-04-05
3
Medium Priority
?
254 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
0
Comment
Question by:Gabriel_Brienza
3 Comments
 
LVL 4

Assisted Solution

by:g_johnson
g_johnson earned 100 total points
ID: 16381658
 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?
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 16381674
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
0
 

Author Comment

by:Gabriel_Brienza
ID: 16381904
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.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question