473,473 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Reading text files

I'm trying to read specific information from a text file. I need to
get stuff like invoice date, invoice number and account number
(9/18/06, 586007, 1543 respectively) i was able to use a stream reader
to display the text in a textbox for viewing, but i want to pick these
items out. I don't even know where to start.

EW1 .FW0 Invoice Date 9/18/06
Invoice No. 586007

PO#
RTL#2650000023
-1
-0
Ship-To |Bill-To
|Acct#- Rte Slm#
TO | CHARGE| 1543 0 1
| |ent: ees pck: SP
| |Driver Collect:
| |
0.00
-1
-0
Qty SUM ------------Description----------------Stock-#--- Itm -Price--
---Total---

Sep 19 '06 #1
3 1138
Dear Mr. Drott,

The procedure would be like this:

1. Declare some string variable (e.g. x As String, InvoiceDate As
String, ...)
2. Declare 3 integer variable (e.g. posi As Integer, t As Integer,
StartData As Integer)
3. Open the file
4. Read file into a string variable
x = sr.ReadToEnd()

5. Get the position of invoice date
posi = Instr(x.ToUpper,"INVOICE DATE")

6. Go to the actual start of the date.
If posi is greater than 0 the string was found.
Then add the length of the string (12 characters)
to the position to start right after it and search for the number.
If posi>0 Then
posi=posi+12
For t = posi To x.Length
If Strings.Mid(x,t,1)<>" " Then
StartData = t
Exit For
End If
Next
End If

7. Go to the end of the date
For t = StartData To x.Length
If Strings.Mid(x,t,1)=" " then
InvoiceString = Strings.Mid(x,StartData,t-StartData)
Exit For
End If
Next

Best Regards,

HKSHK
jo***********@gmail.com wrote:
I'm trying to read specific information from a text file. I need to
get stuff like invoice date, invoice number and account number
(9/18/06, 586007, 1543 respectively) i was able to use a stream reader
to display the text in a textbox for viewing, but i want to pick these
items out. I don't even know where to start.

EW1 .FW0 Invoice Date 9/18/06
Invoice No. 586007

PO#
RTL#2650000023
-1
-0
Ship-To |Bill-To
|Acct#- Rte Slm#
TO | CHARGE| 1543 0 1
| |ent: ees pck: SP
| |Driver Collect:
| |
0.00
-1
-0
Qty SUM ------------Description----------------Stock-#--- Itm -Price--
---Total---
Sep 19 '06 #2

thanks for all the info. let me cruch some of this and see if i can
get it working. thanks again.

Sep 19 '06 #3
i'm sorry this is a first for me. (not quite understanding everything)
is the code below correct? how can i output the date to a lable to
test if it worked? lblTest.text = InvoiceDate?

'Try to read in the Invoice Date
Dim InvoiceDate, x As String
Dim posi, t, StartData As Integer
myReader = New IO.StreamReader(txtReadFile.Text)
x = myReader.ReadToEnd
posi = InStr(x.ToUpper, "INVOICE DATE")
If posi 0 Then
posi = posi + 12
For t = posi To x.Length
If Strings.Mid(x, t, 1) <"" Then
StartData = t
Exit For
End If
Next
End If
For t = StartData To x.Length
If Strings.Mid(x, t, 1) = "" Then
InvoiceDate = Strings.Mid(x, StartData, t - StartData)

Exit For
End If
Next

Sep 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: dunnm | last post by:
This is probably a more appropriate location to post this question. I should have know that since I've found most of the other PHP/PDF information contained in this group. Here's my issue...I...
19
by: Lionel B | last post by:
Greetings, I need to read (unformatted text) from stdin up to EOF into a char buffer; of course I cannot allocate my buffer until I know how much text is available, and I do not know how much...
1
by: Magnus | last post by:
allrite folks, got some questions here... 1) LAY-OUT OF REPORTS How is it possible to fundamentaly change the lay-out/form of a report in access? I dont really know it that "difficult", but...
50
by: Michael Mair | last post by:
Cheerio, I would appreciate opinions on the following: Given the task to read a _complete_ text file into a string: What is the "best" way to do it? Handling the buffer is not the problem...
40
by: googler | last post by:
I'm trying to read from an input text file and print it out. I can do this by reading each character, but I want to implement it in a more efficient way. So I thought my program should read one...
1
by: Hutty | last post by:
I have a program that open text files and compares them, however, when reading files larger than 500kb the programs seems to bomb. I get re-directed to "page not found". Any idea how to get...
2
by: Eshban Bahadur | last post by:
Hello, I want to read (RTF) files in my VB.NET programme. How can i do it. I apply the same method of reading text files, but it does not save the formatting of text like (bold, italics,...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
2
by: Wes Peters | last post by:
Does anyone know of an article that deals with the subject of reading a structured text file using VBA code in Access? Thanks, Wes
7
by: random guy | last post by:
Hi, I'm writing a program which creates an index of text files. For each file it processes, the program records the start and end positions (as returned by tellg()) of sections of interest,...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.