How to print an output text inside a form?

gr391ndra
10-14-2009, 10:37 AM
Hi,
I have a simple program:
I have two forms.
Form 1: have a five command buttons with command for first button
food = "lobster"
form2.show
form2.print food
the command for the second, third, and fourth command button are similar, only different in the name of the variable and the text
My question is, I would like to print the text result from form2 using the fifth command button. I tried:
form2.printform
the only thing that print is just the blank form from form2, without the "lobster" and other text in it.
Is it possible to print these text?

Iceplug
10-14-2009, 12:11 PM
No, you cannot do that, because Print does nothing more than draw the text onto the form (and the text usually disappears when the form is covered).
What you could do instead is use Form2.Caption = Food instead of Form2.Print
That way, you can read the text back with Form2.Caption.
If you need the multiple entries, use a listbox.

vb5prgrmr
10-14-2009, 05:32 PM
Pssst,... Autoredraw... set = true and all done problem solved.



Good Luck

jerome_gail26
10-14-2009, 08:16 PM
the only thing that print is just the blank form from form2, without the "lobster" and other text in it.

Did you mean you want to print the values printed on form 2?

Is it possible to print these text?
Yes. First Declare a Variable on General. then, on every button click pass a value to the variable.

This sample might help you
Dim ValueToPrint As String

Private Sub Command1_Click()
food = "Lobster"
Form2.Show
Form2.Print Food
ValueToPrint = ValueToPrint & vbCrLf & Food
End Sub

Private Sub Command2_Click()
food = "Crab"
Form2.Show
Form2.Print Food
ValueToPrint = ValueToPrint & vbCrLf & Food
End Sub

Private Sub CommandPrint_Click()
Printer.Print ValueToPrint
printer.EndDoc
End Sub


vbCrLf is newline/enter
Printer.Print - print on default printer
Hope this help. :)

Good Luck
Jerome and Gail

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum