CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: printing

  1. #1
    Join Date
    Apr 2001
    Location
    California
    Posts
    20

    printing

    what do I need to do to get the system printer to print text2.text ??



  2. #2
    Join Date
    May 2001
    Location
    Phildelphia Pa.
    Posts
    1

    Re: printing

    You haven't given much information here, so I'll assume you mean from within a VB project...

    All you have to do is open the text file as a file

    Open /text2.txt for input as #1

    then use an object.print...


  3. #3
    Join Date
    Apr 2001
    Location
    California
    Posts
    20

    Re: printing

    I figured it out thanks..
    No the control textBox, (text)
    Thanks



  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: printing

    'Form1(with labels and textboxes)

    ' Print the Labels and TextBoxes.
    Private Sub PrintFormFields(ptr As Object, frm As Form, draw_box As Boolean)
    Dim ctl As Control
    Dim wid As Single
    Dim hgt As Single

    For Each ctl In frm.Controls
    If TypeOf ctl Is Label Then
    PrintText ptr, frm, ctl, ctl.Caption, False
    ElseIf TypeOf ctl Is TextBox Then
    PrintText ptr, frm, ctl, ctl.Text, True
    End If
    Next ctl

    If draw_box Then
    wid = frm.ScaleX(frm.ScaleWidth, frm.ScaleMode, vbTwips)
    hgt = frm.ScaleY(frm.ScaleHeight, frm.ScaleMode, vbTwips)
    ptr.Line (0, 0)-Step(wid, hgt), , B
    End If
    End Sub

    ' Print text where the control belongs.
    Private Sub PrintText(ptr As Object, frm As Form, ctl As Control, txt As String, draw_box As Boolean)
    Dim l As Single
    Dim t As Single
    Dim wid As Single
    Dim hgt As Single

    l = frm.ScaleX(ctl.Left, frm.ScaleMode, vbTwips)
    t = frm.ScaleY(ctl.Top, frm.ScaleMode, vbTwips)
    If draw_box Then
    ptr.CurrentX = l + _
    ScaleX(0.2 * ctl.Font.Size, vbPoints, vbTwips)
    ptr.CurrentY = t + _
    ScaleY(0.2 * ctl.Font.Size, vbPoints, vbTwips)
    Else
    ptr.CurrentX = l
    ptr.CurrentY = t
    End If

    ' Select the printer font.
    ptr.Font.Name = ctl.Font.Name
    ptr.Font.Size = ctl.Font.Size

    ptr.Print txt
    If draw_box Then
    wid = frm.ScaleX(ctl.Width, frm.ScaleMode, vbTwips)
    hgt = frm.ScaleY(ctl.Height, frm.ScaleMode, vbTwips)
    ptr.Line (l, t)-Step(wid, hgt), , B
    End If
    End Sub

    Private Sub cmdPreview_Click()
    Form2.Cls
    PrintFormFields Form2, Me, True
    Form2.Show
    End Sub

    Private Sub cmdPrint_Click()
    Screen.MousePointer = vbHourglass
    PrintFormFields Printer, Me, True
    Printer.EndDoc
    Screen.MousePointer = vbDefault
    End Sub


    'form2 (empty)

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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

Featured