05-19-2003, 09:29 PM
Ok, here goes, I have searched all through this forum, and msdn, and I can't find the answer to this question. I was wondering, how to make the program search for certain Strings in a file that is opened by the user, Find that string, and put whatever is behind that string in a array, such as
So, it searches "1." and adds whatever is behind it, in this case ,"Whatever" to Array(0), or Array(1), or Array(2) and so on. If you don't understand it i will try to clarify, Thanks for your Time
05-20-2003, 12:41 AM
will the period always be between the search target and the data?
05-20-2003, 11:43 AM
No it was just an Example, just wondering how to get it into an array, and I have a second question
How would you do this (Forgive me if what you gave me, answers this)
So, under the first 1. "a" would go in First(0), and the second 1. "d" would go into First(1) and so on until the EOF, or under the First 2. "b" would go into Second(0), and under the second 2. "e" would go into Second(1), would that code that you gave me do that?
05-20-2003, 02:10 PM
Answering your first post, the simplest way would probably be to load the entire file into a single string. Then, use the Instr function to return the position of the target string (store this number in a variable.) Then, use Instr again to locate the position of the next vbNewLine character string after the current position. Your text will lie between these two positions, so use the Mid Function to fetch it.
You can extend this approach to search for all occurrances of a substring within the file string - just look up the Instr and Mid functions in your help, and search this site for useage hints. You will also want to learn about dynamic arrays to hold the data.
05-24-2003, 01:41 PM
But loading an entire file into a string is very memory consuming ins't it? Imagine a 1 or 2 mb text file, like a month old IRC log (like some of mines are)...
Any ideas for that?
05-25-2003, 02:21 AM
a few megabytes shouldn't be a problem. I've opened a 30 MByte file this way with no issues. And, I've loaded a 140 MByte file into an array of bytes with no problems. It took 30 seconds or so to load it all in, and move memory from RAM into virtual memory, but, there were no difficulties with it.