Results 1 to 12 of 12

Thread: [RESOLVED] Need to print data inside Frame control

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2009
    Location
    Erode,TN,India
    Posts
    52

    Resolved [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

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

    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

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2009
    Location
    Erode,TN,India
    Posts
    52

    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?

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

    Re: Need to print data inside Frame control

    Can you just print the form itself?

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2009
    Location
    Erode,TN,India
    Posts
    52

    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.

  6. #6
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    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,...

  7. #7

    Thread Starter
    Member
    Join Date
    Jun 2009
    Location
    Erode,TN,India
    Posts
    52

    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.

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  9. #9

    Thread Starter
    Member
    Join Date
    Jun 2009
    Location
    Erode,TN,India
    Posts
    52

    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.

  10. #10
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Need to print data inside Frame control

    Quote Originally Posted by ttsdinesh View Post
    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,...

  11. #11

    Thread Starter
    Member
    Join Date
    Jun 2009
    Location
    Erode,TN,India
    Posts
    52

    Resolved 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.

  12. #12
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    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
  •  



Click Here to Expand Forum to Full Width