Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-06-2008, 06:08 PM
Lars Brownie
 
Posts: n/a
Insert value into other array values

For example: I have an array with the following stringvalues: "one", "two",
"four". Between the "two" and "four" I would like to insert value "three".
The order is important as I have to 'scan' through the array in that
particular order. Can this be done?
Thanks for any help!
Lars


Reply With Quote
  #2 (permalink)  
Old 01-06-2008, 06:17 PM
Ken Snell \(MVP\)
 
Posts: n/a
Re: Insert value into other array values

Something tells me that your description is a generic one, and that what you
really want to do is something a bit different? Give us specific details, as
it's possible that there is a better, completely different approach to doing
what you seek to do.

Working with arrays usually is more trouble than working with a table's data
when you're wanting to add/remove values from the "array".
--

Ken Snell
<MS ACCESS MVP>



"Lars Brownie" <Lars@Brownie.com> wrote in message
news:flr5es$18hf$1@textnews.wanadoo.nl...
> For example: I have an array with the following stringvalues: "one",
> "two", "four". Between the "two" and "four" I would like to insert value
> "three". The order is important as I have to 'scan' through the array in
> that particular order. Can this be done?
> Thanks for any help!
> Lars
>



Reply With Quote
  #3 (permalink)  
Old 01-06-2008, 06:17 PM
Ken Snell \(MVP\)
 
Posts: n/a
Re: Insert value into other array values

Something tells me that your description is a generic one, and that what you
really want to do is something a bit different? Give us specific details, as
it's possible that there is a better, completely different approach to doing
what you seek to do.

Working with arrays usually is more trouble than working with a table's data
when you're wanting to add/remove values from the "array".
--

Ken Snell
<MS ACCESS MVP>



"Lars Brownie" <Lars@Brownie.com> wrote in message
news:flr5es$18hf$1@textnews.wanadoo.nl...
> For example: I have an array with the following stringvalues: "one",
> "two", "four". Between the "two" and "four" I would like to insert value
> "three". The order is important as I have to 'scan' through the array in
> that particular order. Can this be done?
> Thanks for any help!
> Lars
>



Reply With Quote
  #4 (permalink)  
Old 01-06-2008, 06:34 PM
Albert D. Kallal
 
Posts: n/a
Re: Insert value into other array values

"Lars Brownie" <Lars@Brownie.com> wrote in message
news:flr5es$18hf$1@textnews.wanadoo.nl...
> For example: I have an array with the following stringvalues: "one",
> "two", "four". Between the "two" and "four" I would like to insert value
> "three". The order is important as I have to 'scan' through the array in
> that particular order. Can this be done?


You can do this, but I likely have to ask why you need such a design?

You have this high speed database engine, and we now back to coding and
inserting values into an array that we need to somehow order, and then
additionally write code to search?

Furthermore, where did the original 1-3 values come from? (perhaps the
values should be placed in a table?????).

Something just don't jive right here. In stead of matching a whole bunch of
values against a array in a loop, why not tell the database engine to match
the one value???


Anyway, *if* you must really go back to the punched card days of FORTRAN and
use a array, then you must:


1) redimenstion the array (using the preserve word to keep existing values)
to increase the size of the array by one.

eg:
Dim MyArray() As Integer
Dim j As Integer

ReDim MyArrary(4)
....increase to 5
ReDim Preserve MyArray(5)

note that you MUST declare the array with () (no value) to be able to re-dim
the array
on the fly in code.

2) write a loop to move everything down by one at the spot you need to
insert the value

eg:
move everything up from 3 to 5, make a hole in 2

for j = 5 to 3
MyArrary(j) = MyArrary(j-1)
next j


3) insert the value
MyArrary(2) = new value

I should point out that by default, arrays are *zero* based in access (they
start at zero).

Really, I been writing code in access for a LONG time, and I NEVER had to
use a an array as such. Arrays are just not really for dataprocessing
anymore...and I suspect some type of table based approach here would like
save some good amounts of developer time here....

If the data in the array is read only, then using a collection likely would
be more useful. However, it not clear how/where the original values came
from, and how these values got their way into the array in the first place.


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com


Reply With Quote
  #5 (permalink)  
Old 01-06-2008, 06:34 PM
Albert D. Kallal
 
Posts: n/a
Re: Insert value into other array values

"Lars Brownie" <Lars@Brownie.com> wrote in message
news:flr5es$18hf$1@textnews.wanadoo.nl...
> For example: I have an array with the following stringvalues: "one",
> "two", "four". Between the "two" and "four" I would like to insert value
> "three". The order is important as I have to 'scan' through the array in
> that particular order. Can this be done?


You can do this, but I likely have to ask why you need such a design?

You have this high speed database engine, and we now back to coding and
inserting values into an array that we need to somehow order, and then
additionally write code to search?

Furthermore, where did the original 1-3 values come from? (perhaps the
values should be placed in a table?????).

Something just don't jive right here. In stead of matching a whole bunch of
values against a array in a loop, why not tell the database engine to match
the one value???


Anyway, *if* you must really go back to the punched card days of FORTRAN and
use a array, then you must:


1) redimenstion the array (using the preserve word to keep existing values)
to increase the size of the array by one.

eg:
Dim MyArray() As Integer
Dim j As Integer

ReDim MyArrary(4)
....increase to 5
ReDim Preserve MyArray(5)

note that you MUST declare the array with () (no value) to be able to re-dim
the array
on the fly in code.

2) write a loop to move everything down by one at the spot you need to
insert the value

eg:
move everything up from 3 to 5, make a hole in 2

for j = 5 to 3
MyArrary(j) = MyArrary(j-1)
next j


3) insert the value
MyArrary(2) = new value

I should point out that by default, arrays are *zero* based in access (they
start at zero).

Really, I been writing code in access for a LONG time, and I NEVER had to
use a an array as such. Arrays are just not really for dataprocessing
anymore...and I suspect some type of table based approach here would like
save some good amounts of developer time here....

If the data in the array is read only, then using a collection likely would
be more useful. However, it not clear how/where the original values came
from, and how these values got their way into the array in the first place.


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com


Reply With Quote
  #6 (permalink)  
Old 01-06-2008, 07:43 PM
Lars Brownie
 
Posts: n/a
Re: Insert value into other array values

Thanks Ken, Albert,
OK, understand. I'm able to import the source (text file) into a table, so I
can perform the edit actions on that table.
Thanks for the tip.
Lars

"Albert D. Kallal" <PleaseNOOOsPAMmkallal@msn.com> schreef in bericht
news:%23MDrALJUIHA.1184@TK2MSFTNGP04.phx.gbl...
> "Lars Brownie" <Lars@Brownie.com> wrote in message
> news:flr5es$18hf$1@textnews.wanadoo.nl...
>> For example: I have an array with the following stringvalues: "one",
>> "two", "four". Between the "two" and "four" I would like to insert value
>> "three". The order is important as I have to 'scan' through the array in
>> that particular order. Can this be done?

>
> You can do this, but I likely have to ask why you need such a design?
>
> You have this high speed database engine, and we now back to coding and
> inserting values into an array that we need to somehow order, and then
> additionally write code to search?
>
> Furthermore, where did the original 1-3 values come from? (perhaps the
> values should be placed in a table?????).
>
> Something just don't jive right here. In stead of matching a whole bunch
> of values against a array in a loop, why not tell the database engine to
> match the one value???
>
>
> Anyway, *if* you must really go back to the punched card days of FORTRAN
> and use a array, then you must:
>
>
> 1) redimenstion the array (using the preserve word to keep existing
> values) to increase the size of the array by one.
>
> eg:
> Dim MyArray() As Integer
> Dim j As Integer
>
> ReDim MyArrary(4)
> ...increase to 5
> ReDim Preserve MyArray(5)
>
> note that you MUST declare the array with () (no value) to be able to
> re-dim the array
> on the fly in code.
>
> 2) write a loop to move everything down by one at the spot you need to
> insert the value
>
> eg:
> move everything up from 3 to 5, make a hole in 2
>
> for j = 5 to 3
> MyArrary(j) = MyArrary(j-1)
> next j
>
>
> 3) insert the value
> MyArrary(2) = new value
>
> I should point out that by default, arrays are *zero* based in access
> (they start at zero).
>
> Really, I been writing code in access for a LONG time, and I NEVER had to
> use a an array as such. Arrays are just not really for dataprocessing
> anymore...and I suspect some type of table based approach here would like
> save some good amounts of developer time here....
>
> If the data in the array is read only, then using a collection likely
> would be more useful. However, it not clear how/where the original values
> came from, and how these values got their way into the array in the first
> place.
>
>
> --
> Albert D. Kallal (Access MVP)
> Edmonton, Alberta Canada
> pleaseNOOSpamKallal@msn.com
>
>



Reply With Quote
  #7 (permalink)  
Old 01-06-2008, 07:43 PM
Lars Brownie
 
Posts: n/a
Re: Insert value into other array values

Thanks Ken, Albert,
OK, understand. I'm able to import the source (text file) into a table, so I
can perform the edit actions on that table.
Thanks for the tip.
Lars

"Albert D. Kallal" <PleaseNOOOsPAMmkallal@msn.com> schreef in bericht
news:%23MDrALJUIHA.1184@TK2MSFTNGP04.phx.gbl...
> "Lars Brownie" <Lars@Brownie.com> wrote in message
> news:flr5es$18hf$1@textnews.wanadoo.nl...
>> For example: I have an array with the following stringvalues: "one",
>> "two", "four". Between the "two" and "four" I would like to insert value
>> "three". The order is important as I have to 'scan' through the array in
>> that particular order. Can this be done?

>
> You can do this, but I likely have to ask why you need such a design?
>
> You have this high speed database engine, and we now back to coding and
> inserting values into an array that we need to somehow order, and then
> additionally write code to search?
>
> Furthermore, where did the original 1-3 values come from? (perhaps the
> values should be placed in a table?????).
>
> Something just don't jive right here. In stead of matching a whole bunch
> of values against a array in a loop, why not tell the database engine to
> match the one value???
>
>
> Anyway, *if* you must really go back to the punched card days of FORTRAN
> and use a array, then you must:
>
>
> 1) redimenstion the array (using the preserve word to keep existing
> values) to increase the size of the array by one.
>
> eg:
> Dim MyArray() As Integer
> Dim j As Integer
>
> ReDim MyArrary(4)
> ...increase to 5
> ReDim Preserve MyArray(5)
>
> note that you MUST declare the array with () (no value) to be able to
> re-dim the array
> on the fly in code.
>
> 2) write a loop to move everything down by one at the spot you need to
> insert the value
>
> eg:
> move everything up from 3 to 5, make a hole in 2
>
> for j = 5 to 3
> MyArrary(j) = MyArrary(j-1)
> next j
>
>
> 3) insert the value
> MyArrary(2) = new value
>
> I should point out that by default, arrays are *zero* based in access
> (they start at zero).
>
> Really, I been writing code in access for a LONG time, and I NEVER had to
> use a an array as such. Arrays are just not really for dataprocessing
> anymore...and I suspect some type of table based approach here would like
> save some good amounts of developer time here....
>
> If the data in the array is read only, then using a collection likely
> would be more useful. However, it not clear how/where the original values
> came from, and how these values got their way into the array in the first
> place.
>
>
> --
> Albert D. Kallal (Access MVP)
> Edmonton, Alberta Canada
> pleaseNOOSpamKallal@msn.com
>
>



Reply With Quote
  #8 (permalink)  
Old 01-06-2008, 08:00 PM
Krzysztof Pozorek [MVP]
 
Posts: n/a
Re: Insert value into other array values


Użytkownik "Lars Brownie" <Lars@Brownie.com> napisał w wiadomości
news:flr5es$18hf$1@textnews.wanadoo.nl...
> For example: I have an array with the following stringvalues: "one",
> "two", "four". Between the "two" and "four" I would like to insert value
> "three". The order is important as I have to 'scan' through the array in
> that particular order. Can this be done?
> Thanks for any help!
> Lars



Use collection instead of array. It will be more convenient in this case.

Dim c As New Collection
c.Add "one", "one"
c.Add "two", "two"
c.Add "four", "four"
' You insert "three" now (before "four")
c.Add "three", "three", "four"
' Test:
Debug.Print c(1), c(2), c(3), c(4)


Result:
one two three four

Kris, MVP, Poland
www.access.vis.pl


Reply With Quote
  #9 (permalink)  
Old 01-06-2008, 08:00 PM
Krzysztof Pozorek [MVP]
 
Posts: n/a
Re: Insert value into other array values


Użytkownik "Lars Brownie" <Lars@Brownie.com> napisał w wiadomości
news:flr5es$18hf$1@textnews.wanadoo.nl...
> For example: I have an array with the following stringvalues: "one",
> "two", "four". Between the "two" and "four" I would like to insert value
> "three". The order is important as I have to 'scan' through the array in
> that particular order. Can this be done?
> Thanks for any help!
> Lars



Use collection instead of array. It will be more convenient in this case.

Dim c As New Collection
c.Add "one", "one"
c.Add "two", "two"
c.Add "four", "four"
' You insert "three" now (before "four")
c.Add "three", "three", "four"
' Test:
Debug.Print c(1), c(2), c(3), c(4)


Result:
one two three four

Kris, MVP, Poland
www.access.vis.pl


Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:38 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Debt Consolidation | Repair Bad Credit | Credit Card Consolidation | MySpace Template | Loan



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114