You are here:

Qbasic, Quickbasic/geting data from text file of purchase bill/invoice


I am trying to get invoice records from text file in qbasic.I want to get
Record of Invoice no(first eight no.),Invoice date, Item code,Item name,Pack size,Manufacturer Name,Batch no.,Expiry Date,Rate,MRP,Total cost of Item,Quantity,Free Scheme if any,Discount Total,Vat Rate,Vat Total Amount ,Gross Amount and last Net Amount.
my text file is something like this:(copied 1 line only)

0015562420/11/2014    8  720DERIPHYLLIN RET. 150.    10`s   07        CADILA HEALTHCARE LTD.(GRL)   ZHP3228   07/17     4.08     5.30     40.80   10          .00 2.00      .82 5.00     2.00          .00       .00   1320.00ZYDDERIPTB015000    V20/11/2014
0015562420/11/2014   10  729DUOLUTON L TAB.          21`s.  07        CADILA HEALTHCARE LTD.(GRL)   ZHP2791   06/17    89.31   116.00     89.31    1          .00 2.00     1.79 5.00     4.38          .00       .00   1320.00ZYDDUOLUTBX25000    V20/11/2014
0015562420/11/2014    6 1434ALLEGRA 120.          10`s   AVEN      AVENTIS PHARMA LIMITED        0214540   08/16    90.61   117.68    181.22    2          .00 2.00     3.62 5.00     8.88          .00       .00   1320.00SNFALLEGTB012001    V20/11/2014

Will you please help me?
-Amit Oak

Hi Amit,

How is the data actually divided up?  Are the fields fixed length?  Are they tab-separated?

0015562420/11/2014    8  720DERIPHYLLIN RET. 150.    10`s   07        CADILA HEALTHCARE LTD.(GRL)   ZHP3228   07/17     4.08     5.30     40.80   10          .00 2.00      .82 5.00     2.00          .00       .00   1320.00ZYDDERIPTB015000    V20/11/2014

QBasic can separate some data by just using INPUT #fileno, some_data$

For instance, if I did

OPEN "your_invoices.txt" FOR INPUT AS #1

INPUT #1, first$, second$
PRINT first$, second$


I would get something similar to:

0015562420/11/2014    8

As you can see, your invoice number and date are combined.

If you know if any or all the fields are fixed-size, you could grab a full line and use MID$( line_of_data$, start, length ) to pick the pieces out.

Does that help?


Qbasic, Quickbasic

All Answers

Ask Experts


Alex Barry


I have been a qbasic programmer since 2000, creating games, minor libraries and various small programs. I have experience using interrupts, graphics, file input/output, the mouse cursor, and using libraries. I have also learned FreeBASIC, QB64, c/c++, python, lua, php and html.
I do not claim to be an absolute authority in any language, but I don't mind looking things up and learning with you.


I have been programming in *Basic dialects since 2000, as mentioned in my expertise. After a year of QBasic, I learned C and C++, and dabbled a little in ASM (I don't program in ASM - I literally just played around to see how things work). When QB64 and FreeBASIC were released, I played with those languages. At the time, FreeBASIC offered more functionality and I sided with that language for a while. During that time, while I was learning new languages, that I would see what scripting languages are available, where I took up python and lua. I started to notice a staleness to QB64's development (which I kept tabs on from time to time), and am now trying to be active in it's community and maybe in it's development in the future. Currently, I am only active on the forums, but I appear on occasion on's forums as well.

Highschool - 2007

©2016 All rights reserved.