'Get text between Start/Stop tags? Can anyone help me?, I am trying to have a file full of all sorts of information, and I want to be able to read and project the data on the screen. But I want to say find the text `start` and read all of the lines underneath this line until the program finds the word `stop` and then ignore the text under `stop` and display the text in between start and stop. Is this possible? '-------------------------------------- 'Peter Denton 11/01/98 '-------------------------------------- If start and stop are on a seperate line on there own you could use something like: Sub Command1_Click () text1 = "" Dim tempvar As String Open "c:\filedir\filename.ext" For Input As #1 Do While Not EOF(1) And LCase(tempvar) <> "start" Input #1, tempvar Loop If Not EOF(1) Then Do While Not EOF(1) And LCase(tempvar) <> "stop" Input #1, tempvar If LCase(tempvar) <> "stop" Then text1.Text = text1.Text + tempvar + Chr(13) + Chr(10) End If Loop End If Close #1 End Sub Text1 is a text box with it`s multiline property set to true but you can replace this with another control or the print method. '-------------------------------------- 'John F Stendor 11/2/98 '-------------------------------------- Try this... '******************************************** ' SENT 11/2/98 JFS '******************************************** Sub cmdGatherDataButton() dim sBuffer as String dim bAddText as integer dim bReadData as Integer dim sText as string '--------------------------------------------- ' Initialize variables for sub-routine .. ' Flush the textbox .... '--------------------------------------------- bReadData = TRUE sText = "NO ASCII DATA FOUND" Text1.Text = "" '--------------------------------------------- ' Open yopur ASCII text file ... '--------------------------------------------- Open "c:\yourdir\yourname.ext" For Input As #1 '--------------------------------------------- ' Gather the ASCII test ... '--------------------------------------------- Do While Not EOF(1) And bReadData '--------------------------------------------- ' Grab the input text file data an entire line. '--------------------------------------------- sBuffer = LINE INPUT #1, sBuffer '--------------------------------------------- ' Determine what to do ... '--------------------------------------------- Select Case UCase$(Trim$(sBuffer)) '----------------------------------------------------- ' If you want to start collecting ASCII text data ... ' then turn on the switch ' Make sure you flush the sText variable ' This excludes the START command '----------------------------------------------------- Case "START": sText = "" bAddText = TRUE '--------------------------------------------------- ' If you want to STOP collecting ASCII text data ... ' then turn off the switch ' This excludes the STOP command '--------------------------------------------------- Case "STOP": bAddText = FALSE bReadData = FALSE '--------------------------------------------- ' We have another data type, should we collect it '--------------------------------------------- Case Else if bAddText then sText = sText & sBuffer & Char$(13) & Char$(10) End If End Select Loop '--------------------------------------------- ' Punch the collected data into the TEXTBOX .... '--------------------------------------------- Text1.Text = sText Close #1 End Sub Couple of quick points. 1) Don`t add to a text box dynamically, while processing, create a string variable and then punch it into the control when your done. VB executes faster when it doesn`t have to refresh controls constantly. The text assignment causes a windows SENDMESSAGE everytime you assign a value to it. 2) If you are looking for the START indicator embedded within the text then all you need to do is modify the code to use INSTR() and your off and running. This holds true for the STOP indicator also. Just a few MID$ commands and movement of the sTest string concatenation and you ready to go. 3) Recommendation make the START and STOP indicators unique in the ASCI test file. .START. .STOP. This way you can use the START and STOP as words within the text you wish to select/display. 4) I`m not to sure about the Char$(13) & Char$(10) I always use a listbox when I read ASCII text. It eliminates the memory issues with 64K for a text box and I stay away from textboxs when I have to display more than 10 lines of text. I use the following.... lstMyListBox.additem sBuffer 5) Set the Temporary variable to a value "NO ASCII DATA FOUND" so you know if something went wrong you can trace the code. This is especially valuable when you have to manage multiple files and multiple forms/controls.