|
-
Sep 1st, 2000, 06:38 AM
#1
Thread Starter
Member
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
-
Sep 1st, 2000, 07:33 AM
#2
Addicted Member
could you loop through the array and if ar(x + 1) <> ar(x) + 1 then add the new number?
-
Sep 1st, 2000, 07:43 AM
#3
Lively Member
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
-
Sep 1st, 2000, 09:36 AM
#4
_______
<?>
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|