-
Jul 7th, 2010, 08:19 AM
#1
Thread Starter
Member
[RESOLVED] Need to print data inside Frame control
I am designing an application in which i added 200 text boxes into a frame control. On clicking a button, all the values in the text boxes must be printed in a paper by a printer connected to the computer. Somebody please help me with the code. Thanks in advance
-
Jul 7th, 2010, 11:00 AM
#2
Re: Need to print data inside Frame control
Try
Code:
Dim Contrl As Control
For Each Contrl In Me.Controls
If (TypeOf Contrl Is TextBox) Then
If Contrl.Container.Name = "Frame1" Then
Printer.Print Contrl.Text
End If
End If
Next
Printer.EndDoc
-
Jul 7th, 2010, 11:15 AM
#3
Thread Starter
Member
Re: Need to print data inside Frame control
Mr.Hack. Thank u for ur help. My 200 text boxes are in the form of 20 x 10 matric. When i use ur code the data in the text boxes are printed one below the other. But i need to print the data in the 20 x 10 matriX itself. How to do it?
-
Jul 7th, 2010, 11:18 AM
#4
Re: Need to print data inside Frame control
Can you just print the form itself?
-
Jul 7th, 2010, 11:41 AM
#5
Thread Starter
Member
Re: Need to print data inside Frame control
I want to print only the text boxes. The text boxes are inside a Frame. Atleast if i print the whole frame control, along with the text boxes,its enough.
-
Jul 8th, 2010, 04:29 AM
#6
Re: Need to print data inside Frame control
May be something like this will help ?
Code:
dim i as long
dim Temp as string
Dim Contrl As Control
For Each Contrl In Me.Controls
If (TypeOf Contrl Is TextBox) Then
If Contrl.Container.Name = "Frame1" Then
if i<5 then '~~~ for columns
temp=temp & vbtab & Contrl.Text
i=i+1
else
'~~~ resetting values
i=0
temp=""
Printer.Print temp
temp=temp & vbtab & Contrl.Text
i=i+1
end if
End If
End If
Next
Printer.EndDoc
(untested code)
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Jul 8th, 2010, 05:06 AM
#7
Thread Starter
Member
Re: Need to print data inside Frame control
Is there anyway to print only a portion of the form? If so its easy to find the co-ordinates of the Frame and print the entire form within that co-ordinate.
-
Jul 8th, 2010, 05:39 AM
#8
Re: Need to print data inside Frame control
if you change your frame to a picturebox, it will appear very similar indeed and it is much easier to print the contents of a picturebox
see this example from microsoft about fitting print to page size
http://support.microsoft.com/default...b;en-us;161299
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jul 8th, 2010, 11:39 PM
#9
Thread Starter
Member
Re: Need to print data inside Frame control
Mr.Hack, i have changed my mind. Now its enough to print the form itself. Help me with code to print the entire form.
-
Jul 9th, 2010, 12:36 AM
#10
Re: Need to print data inside Frame control
Originally Posted by ttsdinesh
Mr.Hack, i have changed my mind . Now its enough to print the form itself. Help me with code to print the entire form.
Code:
Private Sub Command1_Click()
Form1.PrintForm
End Sub
.......
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Jul 9th, 2010, 03:13 AM
#11
Thread Starter
Member
Re: Need to print data inside Frame control
Thank u Mr.akhileshbc, Mr.westconn1 and Mr.Hack. I used
Code:
Private Sub Command1_Click()
Form1.PrintForm
End Sub
and solved my problem. Thanks for ur efforts.
-
Jul 9th, 2010, 03:20 AM
#12
Re: [RESOLVED] Need to print data inside Frame control
We are happy to help you...
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
Tags for this Thread
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
|