To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
MSDN Subscribers: Download the VS 2010 Release Candidate
MSDN Subscribers: Download the VS 2010 Release Candidate
Sell Your Code and Make Money?
Creating your own Tetris game using VB.NET
Article :: Improving Software Economics, Part 4 of 7: Top 10 Principles of Iterative Software Management



Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier

Reply Post New Thread
 
Thread Tools Search this Thread Display Modes
Old Oct 17th, 2005, 12:08 PM   #1
KidJavelin
Member
 
Join Date: Jun 05
Location: Poulsbo, WA
Posts: 60
KidJavelin is an unknown quantity at this point (<10)
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
KidJavelin is offline   Reply With Quote
Old Oct 17th, 2005, 12:11 PM   #2
dglienna
Banned
 
dglienna's Avatar
 
Join Date: Jun 04
Location: Center of it all
Posts: 17,901
dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)
Re: Isolating text strings from a file

Post a block that you want to parse
dglienna is offline   Reply With Quote
Old Oct 17th, 2005, 12:18 PM   #3
KidJavelin
Member
 
Join Date: Jun 05
Location: Poulsbo, WA
Posts: 60
KidJavelin is an unknown quantity at this point (<10)
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.
KidJavelin is offline   Reply With Quote
Old Oct 17th, 2005, 12:19 PM   #4
trisuglow
Frenzied Member
 
trisuglow's Avatar
 
Join Date: Jan 02
Location: Horsham, Sussex, UK
Posts: 1,519
trisuglow has a spectacular aura about (100+)trisuglow has a spectacular aura about (100+)
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. Private Sub Form_Load()
  3.   Dim strExample As String
  4.   Dim str1 As String
  5.   Dim str2 As String
  6.   Dim str3 As String
  7.   Dim slash As String
  8.   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."
  9.   str1 = Left$(strExample, InStr(strExample, "XXX") - 1)
  10.   str2 = Mid$(strExample, InStr(strExample, "XXX") + 3, InStrRev(strExample, "XXX") - (InStr(strExample, "XXX") + 3))
  11.   If InStr(strExample, "///") > InStr(strExample, "\\\") Then
  12.     slash = "///"
  13.   Else
  14.     slash = "\\\"
  15.   End If
  16.   str3 = Right$(strExample, Len(strExample) - InStr(strExample, slash) - 2)
  17.   Debug.Print str1
  18.   Debug.Print str2
  19.   Debug.Print str3
  20. End Sub

Also works for example in post #3 (with the last XXX removed).
__________________
This world is not my home. I'm just passing through.

Add yourself to the VBForums Frappr Map!!

Last edited by trisuglow; Oct 17th, 2005 at 12:22 PM.
trisuglow is offline   Reply With Quote
Old Oct 17th, 2005, 12:42 PM   #5
KidJavelin
Member
 
Join Date: Jun 05
Location: Poulsbo, WA
Posts: 60
KidJavelin is an unknown quantity at this point (<10)
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
KidJavelin is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 02:51 PM.




To view more projects, click here

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.