Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Search string

Posted on 2004-10-01
13
Medium Priority
?
181 Views
Last Modified: 2010-05-02
Ok I'm working on a program for personal use through work, now I'm not greatly experienced at programming but have had some practice.  What I want is when the documents for delivery are produced I want to be able to select the whole document and copy it straight to a access, I can do most like copying to clip board and placing them into access, what I'm not sure on is how to filter the clipboard. here's how normal documents look.

[Information needs to be ignored]
{Introduction} This months warehousing deliveries  for date blah blah blah

[needed information]
Day1 Warehouse1 (17:50) sent 615 to warehouse2 (32:4) for shipping
Day3 Warehouse9 (5:30) sent 758 to warehouse14 (45:5) for shipping
Day16 Customer(6:15) returned 1546(product number) back to warehouse (21:6)

The results I want from this is
if sent
The day, warehouse name and the number with the brackets around it, the number of product and the warehouse name and number, now the warehouse can be 2 or 3 words

if returned
the day, customer name and id number, product number and warehouse sent.

with this information I will place in a table.  Thanks in advance
0
Comment
Question by:gb0901a
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 3
13 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 12209640
How are you putting the data into the database?

WHat does the record look like?

mlmcc
0
 

Author Comment

by:gb0901a
ID: 12211141
don't worry about that, all I want is to extract the details into individual strings, that's all I would like to know how to do.

these are the records that need extracting

Day1 Warehouse1 (17:50) sent 615 to warehouse2 (32:4) for shipping
Day3 Warehouse9 (5:30) sent 758 to warehouse14 (45:5) for shipping
Day16 Customer(6:15) returned 1546(product number) back to warehouse (21:6
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12211355
I don't think you can filter the clipboard.

This process sounds more like it should be a program that reads the document and selects only the lines you want.  Can the document be saved a s a text file with carriage returns or line feeds after each line?

mlmcc
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:gb0901a
ID: 12212287
I know we can filter the clipboard, see I used a timer with interval at half a second to take anything from the clipboard.

This was done by

TheString = Clipboard.GetText

All I want to do is filter TheString if that's possible?
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12212521
What does the string have in it?  Is it a single line?

mlmcc
0
 
LVL 7

Expert Comment

by:Enlade
ID: 12212638


Filtering the string is just a matter of walking through the string using Mid$ and picking out what you want.  So long as the string is consistent in its format.  Still, I think that mimcc is a little confused (as am I) about why you want to use the clipboard to pass text into your application.  Why not just read it directly from a text file or something?  Or if the data is already in a DB then read the string directly from the DB.  I think it is just that we don't understand where the data is coming from and we are getting stuck on that part of your problem rather then just writing you a few loops and a few Mid$ calls to parse your string for you.

In any case, the reason we might want to know more about where the string is coming from is that the solution to this problem is dependent on the consistency of your input string (whether it is coming from a file or the clipboard).  So we are just trying to get a little more insight on the format of the input string.  For instance, you say that these are two examples of your input strings:

Day3 Warehouse9 (5:30) sent 758 to warehouse14 (45:5) for shipping
Day16 Customer(6:15) returned 1546(product number) back to warehouse (21:6)

Notice that little differences can be a problem.  For instance, you have a space after "Warehouse9", but no space after "Customer".  Or when you see the string "sent 758 to warehouse14" is that text that is typed in by a user?  For instance, what if the user typed in "sent 758 (6:15) to werehouse14"  where the user puts a "(6:15)" into the string in a place where your function might have trouble with it.

I think what you need to do is to give us a specific example of an input string and a set of output strings that you want.  For instance, lets say your input string is:

Day16 Customer(6:15) returned 1546(product number) back to warehouse (21:6)

Then you might say you want the following output strings:

Day16
Customer
6:15
returned 1546 back to warehouse
product number
21:6

I know that is probably not exactly the output strings you want, but if you list them out like I have done above then maybe mimcc could help you write out a parsing function for you.  Give him a few examples though and be precise (spaces included or not included).  Like for instance in my little example above I took out the "(" and ")" from the output strings (maybe you want them in the output strings, but that is what I mean by being precise--mimcc needs to know that).

0
 
LVL 7

Expert Comment

by:Enlade
ID: 12212644

Oh, and give more realistic examples.  For instance, if "(product number)" is actually something like "(M6-743)" then say that.  Don't say "(product number)" in your examples.  I think it will help mimcc to be working with examples that are more real.
0
 

Author Comment

by:gb0901a
ID: 12213934
OK, no probs, the (product number) is just telling what it is, so normall it's going to be a number.  Also this application is copied from a webpage produced by the company, so everything IS constant, there is no differences between formats.  So if

Day16 Customer(6:15) returned 1546 back to warehouse (21:6)

Only variables such as day, customer (6:15), product number and warehouse is going to change.

For example:

April 9th, YR04 David Bailey (6:15) returned 1546 back to Bolton On Dearne (12:15)

This would be the exact phrase the website would produce, from this I would like to copy onto clipboard, the application would then produce a database with it, al I need to know is extract the date, customer name&no, product number and warehouse name&no, sorrya bout the bad explanation
0
 
LVL 7

Expert Comment

by:Enlade
ID: 12220468

Ok, so let me tell you what I'm afraid of.  I'm afraid that I'm going to write a real simple parse of the input string you gave me above.  Then when you try it on some other input strings it won't work because you haven't completely represented all possible formats of your input string.  Still, maybe we will get lucky.  Let me throw some real simple parse together for you to try.  Be right back.
0
 
LVL 7

Expert Comment

by:Enlade
ID: 12220547

Ok, here is the most simple approuch to solving your problem.  It is completely dependent on the format of the input string that you gave in your example.  So, any other string that isn't in that exact same format will not return what you want.  In any case, it will either work for you or it will help you to better represent your input string format.  Here you go:

http://www.enlade.com/Samples/ParseTest4.zip

You can paste different input strings into the Public Const stParse.  Give it a try and tell me what you think.
0
 

Author Comment

by:gb0901a
ID: 12224771
Ok thanks will do, whatever it will help me understand better!
0
 

Author Comment

by:gb0901a
ID: 12232757
Well it works, kind of, needs some adjustments, although I'm not sure how I would do it with more than 1 record as the positions would be different wouldn't they?
0
 
LVL 7

Accepted Solution

by:
Enlade earned 2000 total points
ID: 12232826

So long as the features that I parsed on stay the same, but that is what I don't know.  You need to start to give more examples of all the different formats for your input string.  Try to think of all the possible formats so that we can find a pattern that can be parsed on so that you always get the information you want.

Keep in mind that it might not be possible to cover all possibilities and thus your problem will not be solvable.  It all hinges on the ability to uniquely distinguish each data item you want to extract.  If the input string has no distinguishable features then it might not be possible to parse a random like string.  But I'm thinking that your data is probably consistent enough to come up with a parse that will work.  The key is to list out enough examples of input strings to cover all that are possible and then sit back and look for the pattern.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question