Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I extract individual elemnents from a date List?

Status
Not open for further replies.

young74

Programmer
Aug 14, 2002
1
GB

Hi,

I am wanting to extract data from a comma seperated list into its individual elements (probably into an array)i.e.

Datelist = "1,4,5,6".

element[1] = 1
element[2] = 4
element[3] = 5
element[4] = 6.

Could someone please supply me the code to extract the individual elements. I know the code for the array part.

As I am a total beginner to VBA, if you know of any good programming books, which would be useful, it would be appreciated.
 
If you are using A2k or A2k2 then there is a function called split which does just what you ask.

Dim Element
Dim datelist As String
Dim x As Integer
datelist = "1,4,5,6"

Element = Split(datelist, ",")

For x = 0 To UBound(Element)
Debug.Print Element(x)
Next x

HTH

B ----------------------------------
Ben O'Hara
Home: bpo@RobotParade.co.uk
Work: bo104@westyorkshire.pnn.police.uk
Web: ----------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top