|
-
Oct 28th, 2005, 01:14 AM
#1
Thread Starter
Hyperactive Member
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.
-
Oct 28th, 2005, 01:20 AM
#2
Re: Where to start
You may want to look for DataReport, the reporting utility of VB6.0 or the Printer object...
-
Oct 28th, 2005, 01:28 AM
#3
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:
Open "myprintjob.txt" For Output As #1
Print #1, vbNewLine & vbNewLine & vbNewLine ' Print 3 blank lines
Print #1, Space$(15) & dteInvoiceDate & Space$(10) & "Page: " & intPageNum
Print #1, vbNewLine & vbNewLine
For i = 1 To NumItems
Print #1, Space$(10) & ItemDesc(i) & Space$(10) & ItemCost(i)
Next i
Print #1, vbNewLine
etc
etc
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Oct 28th, 2005, 01:34 AM
#4
Thread Starter
Hyperactive Member
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.
-
Oct 28th, 2005, 01:42 AM
#5
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!
-
Oct 28th, 2005, 01:59 AM
#6
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:
Dim MyRept As String
MyRept = vbNewLine & vbNewLine & vbNewLine ' Print 3 blank lines
MyRept = MyRept & Space$(15) & dteInvoiceDate & Space$(10) & "Page: " & intPageNum
MyRept = MyRept & vbNewLine & vbNewLine
For i = 1 To NumItems
MyRept = MyRept & Space$(10) & ItemDesc(i) & Space$(10) & ItemCost(i) & vbNewLine
Next i
MyRept = MyRept & vbNewLine
'
' Now send the file to the printer, assuming LPT1
'
Open "LPT1:" For Output As #1
Print #1, MyRept
Close #1
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Oct 28th, 2005, 02:36 AM
#7
Frenzied Member
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.
-
Oct 28th, 2005, 02:42 AM
#8
Frenzied Member
Re: Where to start
and guess what? it worked. here's my code.
VB Code:
Dim myData As String
Open "c:\a.txt" For Input As #1
Open "lpt1:" For Output As #2
While Not EOF(1)
Input #1, myData
Print #2, myData
Wend
Close #1
Close #2
-
Oct 28th, 2005, 03:55 AM
#9
Frenzied Member
Re: Where to start
mmmm. how do u send end of page to the printer thru code? and where is my formatting?
-
Oct 28th, 2005, 04:19 AM
#10
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.
-
Oct 28th, 2005, 06:01 AM
#11
Re: Where to start
 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.
-
Oct 28th, 2005, 01:03 PM
#12
Thread Starter
Hyperactive Member
Re: Where to start
trisuglow,
I would really appreciate your help. I would be very thankfull for a sample project.
-
Oct 28th, 2005, 01:12 PM
#13
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.
-
Oct 28th, 2005, 02:04 PM
#14
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|