Results 1 to 14 of 14

Thread: Where to start

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    476

    Where to start

    Hi,

    I am a 15 year old, a first time user of VB. I developed an application for my father for his car rental business who has almost no knowledge of computers. I am very thank full to all of you guys who always answered any of my questions when ever I asked.

    Now I am at the stage where I have to print the rental contract on a pre-printed form using my application. I don't know where to start. As I mentioned this is my very first time and I have no Idea as to how to even start this process. This contract is a 3 part form and will be printed on a DOT MATRIX printer. I don't want to display it before printing it. I want the application to prepare it without displaying it and send it to the printer.

    I would really appreciate any HELPFULL posts or ideas or suggestions from any of you experienced people.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Where to start

    You may want to look for DataReport, the reporting utility of VB6.0 or the Printer object...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: Where to start

    We used to do this sort of stuff in the 'bad old days'. It's not too hard to do but can take a bit of trial & error to get it right. We were printing multiple reports on pre-printed stationery and so we printed the data to a file and then sent that to the printer as one print job.

    It's all in the spacing. Pre-printed stationery would be set up for standard line & character spacing, so it's just a matter of using a non-proportional printer font (being a dot-matrix this may already be configured as default). Here's some very rough code as an example:
    VB Code:
    1. Open "myprintjob.txt" For Output As #1
    2. Print #1, vbNewLine & vbNewLine & vbNewLine    ' Print 3 blank lines
    3. Print #1, Space$(15) & dteInvoiceDate & Space$(10) & "Page: " & intPageNum
    4. Print #1, vbNewLine & vbNewLine
    5. For i = 1 To NumItems
    6.     Print #1, Space$(10) & ItemDesc(i) & Space$(10) & ItemCost(i)
    7. Next i
    8. Print #1, vbNewLine
    9. etc
    10. etc
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    476

    Re: Where to start

    pnish, thanks a lot for the sample code. But why did you say 'BAD OLD DAYS'? you mean to say now a days it is not recomended to print on a pre-printer form on a dot matrix printer? Could you shed some more light as to what is better?

    Another thing, how would you close the file and then send it to the parallel port?

    Again thanks a lot for your help.

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Where to start

    Download CutePDF, which is a printer driver. You can send your print-outs to this driver, which gets saved to the hard drive. You open the files with Adobe AcroRead (free) and can print them out if they look right. You can also hold them behind your forms to make sure that they line up before you actually try to print on a real form

    You probably won't have much trouble printing on a form. The next step would be creating the form and printing on it, so you don't have to buy pre-printed forms.

    Good Luck!

  6. #6
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: Where to start

    I guess I say 'bad old days' because now I have access to laser printers and use software like Crystal Reports to print 'nice' looking reports, forms etc. No more pre-printed stationery, we just print our own.

    This old system was on a DEC VAX computer and sending the file to the computer was simple, just copy the file to the print device. In VB, I'm not quite sure how this would work. Perhaps what you could do, instead of printing to a file, is 'print' to a string variable using similar code to what I posted above, eg
    VB Code:
    1. Dim MyRept As String
    2. MyRept = vbNewLine & vbNewLine & vbNewLine    ' Print 3 blank lines
    3. MyRept = MyRept & Space$(15) & dteInvoiceDate & Space$(10) & "Page: " & intPageNum
    4. MyRept = MyRept & vbNewLine & vbNewLine
    5. For i = 1 To NumItems
    6.     MyRept = MyRept & Space$(10) & ItemDesc(i) & Space$(10) & ItemCost(i) & vbNewLine
    7. Next i
    8. MyRept = MyRept & vbNewLine
    9. '
    10. '    Now send the file to the printer, assuming LPT1
    11. '
    12. Open "LPT1:" For Output As #1
    13. Print #1, MyRept
    14. Close #1
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  7. #7
    Frenzied Member
    Join Date
    May 2003
    Location
    Sydney
    Posts
    1,123

    Re: Where to start

    the good bad old days. i used to do the same with my gwbasic and the later "oh so cool" qbasic. i wonder if vb supports this type of printing. i'm about to try in my "NEW" Epson LQ-2180 Dot Matrix printer.

  8. #8
    Frenzied Member
    Join Date
    May 2003
    Location
    Sydney
    Posts
    1,123

    Re: Where to start

    and guess what? it worked. here's my code.
    VB Code:
    1. Dim myData As String
    2.  
    3.     Open "c:\a.txt" For Input As #1
    4.     Open "lpt1:" For Output As #2
    5.  
    6.     While Not EOF(1)
    7.         Input #1, myData
    8.         Print #2, myData
    9.     Wend
    10.  
    11.     Close #1
    12.     Close #2

  9. #9
    Frenzied Member
    Join Date
    May 2003
    Location
    Sydney
    Posts
    1,123

    Re: Where to start

    mmmm. how do u send end of page to the printer thru code? and where is my formatting?

  10. #10
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: Where to start

    Do you have MS Word on the PC. If so you may find it easier to do your printing through that. I can put together an example project if you want help getting started.
    This world is not my home. I'm just passing through.

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Where to start

    Quote Originally Posted by trisuglow
    Do you have MS Word on the PC. If so you may find it easier to do your printing through that. I can put together an example project if you want help getting started.
    Beat me to the suggestion...

    I would like to take what trisuglow said one step further. I believe the simplest approach to this problem would be to make a template for the car rental agreement in Word. Have a VB screen that allows the rental person to fill in all the blanks, pass that information over to your Word template, and use Word to do your printing.

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    476

    Re: Where to start

    trisuglow,

    I would really appreciate your help. I would be very thankfull for a sample project.

  13. #13
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Where to start

    I've created a receipt with a few tables in Word, and saved it as a RTF, so I can open it into a Rich Text Box in my app. I have numbered fields in the rtf [1],[2] that I then use .Find to select, and then .SelText to replace with variables from my app. I even replace a picture before printing.

    Word is not needed to create a print out.

  14. #14
    Frenzied Member
    Join Date
    Aug 2005
    Posts
    1,042

    Re: Where to start

    Newtester:

    I did this quite sometime ago and I don't remember exactly how I did it, but it went something like this:

    First I scanned the form and made a jpg or gif.
    Then I added a new form to my project.
    I put two picture boxes on the form, one inside of the other and added vertical and horizontal scroll bars so I could move the image around and see the whole thing.
    Then I added the image to the inside picture box.
    I put textboxes, etc. on the image where I needed certain information and set the appearance property to 0-flat and the borders property to 0-none.
    Then I wrote the code to get the information from a database or some other part of my application to appear in the appropriate textbox.
    In my print code I set the visible property of the image to False so the image did not print, only the information in the textboxes, onto the blank form in the printer.

    I do recall that I had a bit of a problem getting the scroll bars to work so I could see the whole image and then I had to make several test printings on blank paper (as someone else mentioned above) and hold them up to my form to see how it lined up and then adjust accordingly. After that it worked great.

    Wish I still had the code for you, but it is long gone.

    I'm not sure this will help you, but you might play around with it a little and see.

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