Results 1 to 4 of 4

Thread: PPPLLLLEEEAAASSSEEE help with Array Problem

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    London, UK
    Posts
    39

    Angry PLEASE Help with Array Problems :(

    Hi,

    Does anyone know how to get vb to look at an array of numbers, and then generate the next number that is not shown in an access database

    For instance,

    1
    2
    3
    5
    6
    7

    Vb will look at this in an access database and will generate the number 4. If then it does it again, it will find no gaps and so create a new number 8.

    I really need help with this. PLEASE HELP ME.

    I will be very greatfull

  2. #2
    Addicted Member
    Join Date
    May 2000
    Posts
    188
    could you loop through the array and if ar(x + 1) <> ar(x) + 1 then add the new number?

  3. #3
    Lively Member The_Fog's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Posts
    65

    Question hmm.. I wonder..

    Can't you pick the first and last number in the array, and then generate all numbers in between?
    like this:

    Public Function Generate()
    dim FirstNum as integer
    dim LastNum as integer
    dim TempString as string
    dim myArray

    FirstNum = 0 'Or whatever the first number is.
    LastNum = 10 'Or whatever your last number is.
    for a = FirstNum to LastNum
    TempString = TempString & a & ";"
    next a
    myArray = split(TempString,";",-1,vbTextCompare)
    End Function

    This piece of code will create an Array containing the all numbers between (and included) the FirstNum and the LastNum.
    Hopes this helps.

    The Fog
    They will try to steal everything you own,
    It goes on and on and on...


    Pain - On and On

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'assuming you have an array
    'Dim myArr()
    'and the array is loaded
    'generate numbers from 1st to last
    'same idea as above just less code and no hard coding 
    'of numbers as it reads the present array
    
    Dim x As Integer
    
     For x = (myArr(LBound(myArr))) To myArr((UBound(myArr)))
        ReDim Preserve myArr(x)
           myArr(x) = x
     Next
    tried to fill in the gaps..but I give up.

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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