Results 1 to 5 of 5

Thread: [RESOLVED] Isolating text strings from a file

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Poulsbo, WA
    Posts
    60

    Resolved [RESOLVED] Isolating text strings from a file

    Howdee all !

    I have an application that hacks down a text file for viewing/db import. While its working now(with help from folks here, thanks !) I have a new problem. one field that already gets seperated out for display/view needs to be refined further.

    There is a general text "block" that has to be seperated into three seperate text strings so the DB import can put them into the appropriate fields. The three strings have their own desiginator characters, and I thought I would just parse the string then hold them into seperate memory spaces via varible declarations in the import sub function. Problem is, I'm not sure how parse/seperate the text in VB6 because I'm THAT much of a newbie.

    The seperators are -
    No characters is the basic problem description that comes in originally.
    XXX denotes update remarks for the particular entry.
    /// OR \\\ denotes a close to the entry in question.

    EXAMPLE -
    Original problem gets listed, it's usually a fairly short string. XXX Problem gets some sort of update text. XXX Maybe some more update text gets added here. /// Then they close the problem report for that particular entry like this.

    Can anyone explain to me how to pull this off?

    John

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Isolating text strings from a file

    Post a block that you want to parse

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Poulsbo, WA
    Posts
    60

    Re: Isolating text strings from a file

    4320010205 N/ADURING NORMAL OPERATION, DISCOVERED MALFUNTIONING * IN SUPPLY OFFICE. UPON INVESTIGATION FOUND WORN GEARS DUE TO BROKEN TENSION SPRING.
    XXX REQUEST NEW * FROM SUPPLY SYSTEMTO REPAIR STATION IN SUPPLY OFFICE.XXX SUPPLY INDICATES NO * LEFT ON BOARD, REQUEST TO RECEIVE PARTS DURING PORT CALL.\\\XXX PARTS RECEIVED ALL WORK COMPLETED, NO FURTHER ACTIONS REQUIRED.

    This is what one typically looks like. The * is text I removed. Can't let everyone see that stuff .

    The "XXX" at the end after "\\\" would be removed in the viewer before export.

  4. #4
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: Isolating text strings from a file

    This is hideously bad code, but it works on the first example you gave.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.   Dim strExample As String
    5.   Dim str1 As String
    6.   Dim str2 As String
    7.   Dim str3 As String
    8.   Dim slash As String
    9.   strExample = "Original problem gets listed, it's usually a fairly short string. XXX Problem gets some sort of update text. XXX Maybe some more update text gets added here. /// Then they close the problem report for that particular entry like this."
    10.   str1 = Left$(strExample, InStr(strExample, "XXX") - 1)
    11.   str2 = Mid$(strExample, InStr(strExample, "XXX") + 3, InStrRev(strExample, "XXX") - (InStr(strExample, "XXX") + 3))
    12.   If InStr(strExample, "///") > InStr(strExample, "\\\") Then
    13.     slash = "///"
    14.   Else
    15.     slash = "\\\"
    16.   End If
    17.   str3 = Right$(strExample, Len(strExample) - InStr(strExample, slash) - 2)
    18.   Debug.Print str1
    19.   Debug.Print str2
    20.   Debug.Print str3
    21. End Sub

    Also works for example in post #3 (with the last XXX removed).
    Last edited by trisuglow; Oct 17th, 2005 at 11:22 AM.
    This world is not my home. I'm just passing through.

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Poulsbo, WA
    Posts
    60

    Re: Isolating text strings from a file

    Yep, works like a charm. Now I just have to figure a way to work with the inconsistencies of the reporting.

    Thanks!
    John

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width