Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using arrays with strings

Status
Not open for further replies.

met

IS-IT--Management
Jul 1, 2000
13
US
how do i populate&nbsp;&nbsp;a two dimensional array when using the left() and mid() functions to filter the data. In other words: if&nbsp;&nbsp;I have rows of data in a text file like 1001123456654321 and i want do something like left$(textfile,4) and mid(textfile,5,6)what is the syntax for&nbsp;&nbsp;populating such that i wind up with an array that has two colums ,one containing the left() data and one containing the mid() data with rows being until EOF.<br>Thanks..........<br>MET&nbsp;&nbsp;
 
... operative word&nbsp;&nbsp;here is <i><b>'array'</b></i>.<br><br>Don't know how many elements that this array will have but; I use have been accused of using&nbsp;&nbsp;JET '.MDB's to store 'array' members, when the array size had grow large.<br><br>Typically an array needs to have specific functionality. It needs to function as a linked list, a stack, or whatever. A Jet '.MDB' may provide this functionality (through SQL) for you.<br><br><b>Hint: Use tables to store array elements</b>.<br><br>have fun !. <p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br>
 
Or something like this might work<br><br>dim Array() as string<br>dim i as integer<br><br>redim array (2, 0 )<br><br># Open file stuff #<br><br>do while ( not textfile.eof)<br>&nbsp;&nbsp;&nbsp;textfile = # read from file #<br>&nbsp;&nbsp;&nbsp;redim preserve array( 2, ubound(array)+1)<br>&nbsp;&nbsp;&nbsp;array(0,ubound(array)) = left$(textfile,4) <br>&nbsp;&nbsp;&nbsp;array(1,ubound(array)) = mid(textfile,5,6)<br>loop<br><br>#close file #<br><br>This should do it.&nbsp;&nbsp;it seems to me that adding an ado recordset or even creating a table in a database to accomplish such a task is overkill.&nbsp;&nbsp;Have we forgot about overhead?&nbsp;&nbsp;When did a small text file filter turn into a 2M program?&nbsp;&nbsp;Just my 2 cents <p>Clayton T. Paige<br><a href=mailto:cpaige@home.com>cpaige@home.com</a><br><a href= Snail</a><br>Clayton T. Paige<br>
Programmer Extraordinaire <br>
========================================================<br>
"Who General Failure? and Why is he reading my disk drive?
 
Clayton is on the money, The key to success with multidimensional arrays is identifying how the indicies perform in the relationship.&nbsp;&nbsp;By assuring your understanding of the purpose of each index you can easily adapt a 2, 3, or 17 dimension array.<br><br>You need a Row and column index, how you arrange them is of no consequence unless you need a specific memory orientation.&nbsp;&nbsp;All you have to do is remain consistent.<br><br>My preference is to vary the leftmost index, using the rightmost one as the known size.&nbsp;&nbsp;I think it comes from a piece of information I picked up long ago about how arrays are stored in memory.&nbsp;&nbsp;I haven''t done the foot work to know how VB is storing it, it's just a habit.<br><br>I'll bet all you were looking for was use MyArray(index1, index2). <p>Wil Mead<br><a href=mailto:wmead@optonline.net>wmead@optonline.net</a><br><a href= > </a><br>
 
True, I did admit that it was probably questionable, and&nbsp;&nbsp;use it only for large arrays, It's a waste of some recources otherwise but it's so much simpler that way in many cases! <p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br>
 
Thanks Clayton I was pretty close when I was attempting to do this using arrays-- I was using static indices for reDim instead of using Ubound() and was running out of array range. Can I take this opportunity to ask another question?(ask a lot of questions,huh?)Is their a way without creating a project group (vb6,enterprise)to save a project under another name while in the vb enviornment. Like if you want to make some changes to your code and save them but also save the original. Thanks again, you guy's are great!&nbsp;&nbsp;
 
You can go under File and click Save Project As, but that only saves the project file and not all the forms and modules and I'm thinking you want everything saved.&nbsp;&nbsp;&nbsp;<br><br>What I do when I want to do something like that is save my entire project in one directory and all related file.&nbsp;&nbsp;When I want to save one version of the source code, I just make a copy of the entire directory.<br><br>You could even write a small VB program to do it for you.&nbsp;&nbsp;:)) <br>But, that's a different story<br> <p>Clayton T. Paige<br><a href=mailto:cpaige@home.com>cpaige@home.com</a><br><a href= Snail</a><br>Clayton T. Paige<br>
Programmer Extraordinaire <br>
========================================================<br>
"Who General Failure? and Why is he reading my disk drive?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top