![]() |
|
|
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. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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 |
|
|||
|
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 > |
|
|||
|
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 > |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 > > |
|
|||
|
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 > > |
|
|||
|
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 |
|
|||
|
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 |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|