![]() |
| ||
| text file strings help I ask for simple help. I'm at a part of my application where I need it to open a text file, and search for id numbers within the text. There will be several instances of "id=######"s that I will need to grab from the text file, and put them line by line into another box so that I'm able to save just those id's that i want. so... here's what I need for my program to do: Open .txt, find just the number part of the "id=xxxxxx", and put them one by one into another text field so that i'm able to save them as another text file, keeping just the ripped strings that contains the ids, ya know? I hope i'm making sense.. any help would be greatly appreciated. |
| ||
| Re: text file strings help Open .txt file |
| ||
| Re: text file strings help I have a pretty good idea of what you mean..... you don't want the new text file to just have ID's right? You want it to have ID's AND the information that is attached to those ID's..... but only the one's that have been selected by the GUI. right? Please also post a portion of the .txt file that contains the ID's, so I can see the best method to go about parsing the data. |
| ||
| Re: text file strings help Open <File Path/Name> for input as #1 while not EOF(1) Line Input #1,Str1 take the rest of the string and do what you need with it End loop |
| ||
| Re: text file strings help Hi Try With this Code Dim ReqStr as string |
| ||
| Re: text file strings help The above post may or may not work, depending on if the ID= portion of the string is NOT the first portion of the line... for example: hello;this is alineID=54678 and some stuff. If the line starts with the ID, then it will work to extract the ID portion and save the rest in a variable, but it won't extract the actual ID number. If you could post a portion of the .txt file, we could put together a much more efficient function for you. |
| ||
| Re: text file strings help lets say that this is a line in your input text file; this is aline"ID=54678" and some stuff the code will be ****************** dim x() as string there may be another problem here , lets make line moe complex like; line1"ID=54678" sdf dfgdfg dgdf "ID=5555"ad aewrre"ID=567" asa"ID=5566" iiiiiiiiiiii"ID=9999" here the line may have more than one ID and not a fixed number (as you can see the 1st line has 3 IDs while the 2nd only 2) so what to do??? here you want to take values between each "ID=" then remove the unwanted string by splitting according to the quotation """",but the number of "ID=" not always the same.so you have to use the Ubound function which returns the number of cells in your array x as you will see in the code below You take x(1),x(3),x(5),........till you reach the upper bound of x or less (you cant exceed than the upper bound) But why to begin with x(1) not x(0)?? that is because you want what is between "ID=" and next "ID=" so if you take x(0) you will get wrong terms the code will be ****************** dim x() as string Hope this helps solving the problem :) |
| All times are GMT -4. The time now is 11:02 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC