[resolved]printing values from notepad to the printer
hi i was wondering if someone can help me out. i wanted to print the values stored in the notepad file to the printer when i hit the command button. thx
Private Sub cmdlabel_Click()
Open "database.txt" For Output As #1
Print #1, txtnamest
Print #1, txtaddressst
Print #1, txtaddressst1
Print #1, txtcityst, txtstatest, txtzipcodest
Print #1, txtcountryst
Close #1
End Sub
Re: printing values from notepad to the printer
also for this line
Print #1, txtcityst, txtstatest, txtzipcodest
i was wondering if i can take out those spaces in between when it gets stored in notepad.
Re: printing values from notepad to the printer
try print #1, txtcityst & txtstatest & txtzipcodest
but if you want to separate the txts you will have to do that your self like
print #1, txtcityst & "," & txtstatest & "," & txtzipcodest
change the comma if you prefer some other separator, or put a space
to print the same to a printer
vb Code:
Print.print txtnamest
Print.print txtaddressst
Print.print txtaddressst1
Print.print txtcityst, txtstatest, txtzipcodest
Print.print txtcountryst
printer.enddoc ' finished so print and feed the paper out
if you want to set the font or font size etc do that before the code above
Re: printing values from notepad to the printer
Quote:
Originally Posted by likewhoa
i was wondering if i can take out those spaces in between when it gets stored in notepad.
Wouldn't everything run together making it difficult to read?
Re: printing values from notepad to the printer
yess it worked thank you !!!
Re: printing values from notepad to the printer
actually those spaces were more like tabs in between so they were too far apart.
Re: printing values from notepad to the printer
hi i tested it but it does not print on the printer. but the spaces are ok now
Re: printing values from notepad to the printer
Quote:
Originally Posted by likewhoa
hi i tested it but it does not print on the printer. but the spaces are ok now
What does it do?
Re: printing values from notepad to the printer
My guess would be it doesnt print correct. :D
This line with commas should be semi-colons will keep it on the same line.
Print.print txtcityst, txtstatest, txtzipcodest
Change to
Print.print txtcityst; txtstatest; txtzipcodest
Also, use ShellExecute API to print the text file just as if you did it manually from notepad.
Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const SW_HIDE As Long = 0
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWMINIMIZED As Long = 2
Private Sub Command1_Click()
ShellExecute Me.hwnd, "print", "C:\Users\Public\Test1.txt", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
Re: printing values from notepad to the printer
Quote:
Change to
Print.print txtcityst; txtstatest; txtzipcodest
you missed my error
all lines should be printer.print
the comma will just print in the next print position, so should work fine, otherwise you can just print the identicle line you print to the file
printer.print txtcityst & "," & txtstatest & "," & txtzipcodest
Re: printing values from notepad to the printer
im getting a error when i use the printer.print on all the lines. for the shellexecute can i just type that or do i have to do something special.
Re: printing values from notepad to the printer
Quote:
im getting a error when i use the printer.print on all the lines.
what error? it should work fine
are you working in vb6?
Re: printing values from notepad to the printer
ok now i got it to work it prints but im having trouble changing the font size can someone help me out thank you. this is what i have right now
Printer.Print txtnamest
Printer.Print txtaddressst
Printer.Print txtaddressst1
Printer.Print txtcityst & ","; txtstatest; " "; txtzipcodest
Printer.Print txtcountryst
Printer.EndDoc
End Sub
Re: [resolved]printing values from notepad to the printer
printer.font.size = 14
set the font, size, colour etc before printing the lines, you can change size between lines