Results 1 to 4 of 4

Thread: Required: Someone very smart to solve this

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    Sydney, Australia
    Posts
    196

    Post

    I need a table in my application so i am using a recordset that i create myself (by appending fields to the fields collection) - because the fields in the table have different datatypes (strings, ints, singles)

    One of the fields that i want to include in the table is actually an array (variable length) of singles.

    Does anyone know how i can add a field as an array to a recordset? I've tried using the "adArray" and "adUserDefined" constants for the Type of fields. I've since learned that adArray is in the msdn documentation but does not actually exist.

    I'll be really interested if anyone can think of a good way to do this.

    Mark,

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    This isn't a pretty way to do it but it should work:

    Make a memo field. Then, when you need to add the array to the table, do a loop that will go through the array adding the elements with a comma between them.

    dim strTemp as string, intI as integer

    for intI = 0 to 14
    '14 being the number of elements in your array

    strTemp = strTEmp & strArray(intI) & ","
    next inti

    then write the strTemp into your table. I would write the arrays element count as the first entry - then you can pull that info out to use when you read the field out.

    Use the inStr() and MID functions to find the commas and to pull out the variables. Hope this helps.


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    Sydney, Australia
    Posts
    196

    Post

    Thanks, i will try that - i think it should work quite well for my purposes - the array count is a good idea too.


  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    Sydney, Australia
    Posts
    196

    Post

    One more thing i found if anyone is interested:

    If the array is an array of strings you can use the join function like:

    join(strarray,",") instead of the loop involving

    strTemp = strTEmp & strArray(intI) & ","

    as posted by NetSurfer.

    In the same way you can use the Split(strarray,",") function to return the array of strings back to you.

    I believe this only works with arrays of string and these functions are only defined under VB6

    Edited by funkyd77 on 02-22-2000 at 10:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width