Results 1 to 13 of 13

Thread: [RESOLVED] Formatting grid data for dos printing. Help Needed!!

Hybrid View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2013
    Posts
    66

    Resolved [RESOLVED] Formatting grid data for dos printing. Help Needed!!

    Hi-all
    I have data in my grid (farpoint spread or msflexgrid) in vb6 applications which I need to print in tabular form (bills etc.) with headers and footers or some other
    details. I have tried all the built in functions to carry out formatting but they are not working. Sometimes there are no column lines,row lines and sometimes i am not
    able to add headers or additional data.

    What i am doing currently is getting the length of the longest value/text in each column,setting the '|' character for borders with that length apart and laying out data
    each line. This gets extremely tedious. Sometimes I have to align each row in a column right if it contains numeric data and middle if it contains dates or exclude
    some columns etc. Then I print this text file with command from vb6.

    What I need is any simple logic to add some details like shop name,customer name,bill date and then write a table with data from my control. Something like laying out
    data in an html file with table and printing it in a dos printer. (When I try this, whole html code gets printed).

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Formatting grid data for dos printing. Help Needed!!

    Is there a reason you are not using a report? This would make the printing simple.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2013
    Posts
    66

    Re: Formatting grid data for dos printing. Help Needed!!

    Yes, I should use dos printer only. They have to print continuously,with great speed. Also small paper. Also I have no choice.
    Last edited by BlueFox; Aug 19th, 2013 at 05:16 AM.

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Formatting grid data for dos printing. Help Needed!!

    what do you mean by Dos Printer?
    How does that stop you from using a report?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2013
    Posts
    66

    Re: Formatting grid data for dos printing. Help Needed!!

    Meant dot matrix printer. The firm i work do not want reports. They want to use this technique.

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Formatting grid data for dos printing. Help Needed!!

    Well report tools are designed to do this, the right tool for the job always makes life easier.
    Of course you can use other methods if you want to write the code. The fact that it is a dot matrix printer makes little to no difference other than they are slower than a laser would be and they can do carbon copies and of course are very noisy.

    Would be hard to give you any advice without knowing what you are doing now. I have written code in the past to print onto multi-part pre-printed forms on a dot matrix printer. My solution was to make everything soft and include a settings page. The reason was that should the layout of the form or paper size change in the future then they just needed to change some numbers to get the program to print as needed. I used the printer.currentx and printer.currenty to position each field, keep count of number of detail lines printed, where the detail starts, line spacing and how many lines per page as well as header and footer info and then send the data to the printer.

    Sounds like you are creating a text file and sending that to the printer but again I really have no idea what you have done as you did not include any code nor give a very clear picture of how you coded it.

    Bottom line is that if you want something to do what you mention at the bottom of your post a good report tool is the ticket else you will need to write a function that does this yourself.


    The firm i work do not want reports.
    What you are doing is a report. You are just doing it the hard way.
    Last edited by DataMiser; Aug 19th, 2013 at 06:14 AM.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jul 2013
    Posts
    66

    Re: Formatting grid data for dos printing. Help Needed!!

    I know datareport in vb6. I have done it. I cannot post the code because it belongs to the company. What it does is open a text file, add heading top center, add details like date,name etc, then load the grid data in a tabular format with character '|' acting as column with 2 spaces plus the length of the longest text in a column as length (for each column). The printing paper might be preprinted with text like 'Name:','Date:' etc. They only allow me to use crystal/data reports while displaying details of total sales in a day or month. They use the 'text-Technic' in individual sales like buying 2 burgers and cofee.
    Also I have figured out writing code in html to generate table with data. But i have one question.How do i print it in dos print mode using dot matrix printer?

  8. #8
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Formatting grid data for dos printing. Help Needed!!

    You can print from VB using the Printer object

    to print data from a text file you may do something like

    Code:
    Open FileName for Input as #FileHandle
        Do While Not EOF(FileHandle)
             Line Input #FileHandle, LineOfText
             Printer.Print LineOfText
        Loop
    Close #FileHandle
    Printer.EndDoc
    of course this will print the text that is in the file and not use any HTML formatting instead it will print the tags as text.

    To input HTML and output formatted text you need to use something that can read html and print the formatted text such as a web browser


    why would you be trying to print in dos mode? Dos has not been on any system since Windows 98
    Last edited by DataMiser; Aug 19th, 2013 at 07:25 AM.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jul 2013
    Posts
    66

    Re: Formatting grid data for dos printing. Help Needed!!

    They say clients choose dot matrix because it saves money and 'it is faster' though i do not know the second one. I can attach a web browser control to my project and process the html code. Can I pass that 'processed text' to printer from my form? Leaving office, I will try writing html code tomorrow

  10. #10
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Formatting grid data for dos printing. Help Needed!!

    Dot Matrix is not faster than Laser, not even close. While you will often hear the term pages per minute this really only applies to laser printers as they print x pages per minute be there 1 character of text on the page or a high res photo the speed is the same and it is fast. DotMatrix prints in characters per second. The more characters on the page the longer it takes to print the page. An average dot matrix printer can print maybe 2 lines of text in the time it takes a Laser to spit out a page no matter what is on the page.

    There are a few high speed Dot matrix printers out there but even the fastest ones are slow compared to the fastest lasers.

    There are of course reasons to choose dot matrix the most common of which is carbon copies [multi-part forms] these require an impact printer to generate the carbon copy and is mostly what dot matrix is used for.

    Of course my question was why would you be trying to print from DOS mode. Note that has absolutely nothing to do with the printer being dot matrix.

    As for printing 'processed text' I have no clue what you mean by that.

    You can print text, you can print images, you can send printer control codes

  11. #11
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Formatting grid data for dos printing. Help Needed!!

    It isn't clear at all what you are trying to do.

    How To Send Raw Data to a Printer Using the Win32 API from Visual Basic might be a solution, though it puts some burdens on your program:

    • Synchronous calls that may lock your program up and render it unresponsive at times.
    • The need to deal with the escape sequences of every different printer the customer might want to use, through hard coding or config files, etc.


    To work at an even lower level means additional burdens. You need to be able to "steal" the printer from Windows to take over the port it is connected to. Not too bad for a COMnn: port printer, uglier for parallel port printers, lots of work for USB printers, and potentially even more complex for a networked printer.


    None of that has anything to do with creating a report layout, which seems to be what you are actually asking for (headers, footers).

    Do you have two unrelated questions? Or maybe one question caused by the other one (i.e. printing in dumb mode means you have to write your own report formatting logic)?
    Last edited by dilettante; Aug 19th, 2013 at 10:01 AM.

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Jul 2013
    Posts
    66

    Re: Formatting grid data for dos printing. Help Needed!!

    They say dos mode printing is faster and dot matrix is cheaper. I have no choice. My only question is about report layout in a text file
    I am marking this thread as resolved as I have decided to go with the current technic
    Last edited by BlueFox; Aug 20th, 2013 at 02:42 AM.

  13. #13
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: [RESOLVED] Formatting grid data for dos printing. Help Needed!!

    They say dos mode printing is faster and dot matrix is cheaper.
    The PC in any mode is faster than any Dot Matrix printer so unless you are using a serial connection at 9600 baud the speed of the program is not going to be a factor.
    If anything writing to a file and then printing the file would be slower not faster as the disk drive is one of the slowest parts in modern computers.

    Then again I still do not know what you mean when you say Dos mode as Dos no longer exists and VB6 programs do not run in Dos.

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