点一下按钮,然后打印出来6个文本框的数据,但6个数据得控制打印位置,就是说在程序里把打印的位置给设置好,怎么做啊各位?

解决方案 »

  1.   

    用vb  pinter object 
      

  2.   

    见下列网址的讨论:
    http://topic.csdn.net/u/20070209/16/c56a74a0-89d1-4641-adff-b26f2e4c2061.html
      

  3.   

    东北人都是活雷锋!
    http://topic.csdn.net/u/20071205/11/271143e3-d4b8-487e-a54d-865ca137aa37.html
      

  4.   


    Option Explicit
    Private X As Integer
    Private Y As Integer
    Private fnt As Integer
    Private txt As Variant
    Private dy As Variant
    Private dd As VariantPublic Function prnt(X As Variant, Y As Variant, fnt As Variant, txt As Variant)
    Printer.CurrentX = X
    Printer.CurrentY = Y
    Printer.FontSize = fnt
    Printer.Print txt
    End FunctionY = 450
    X = 1000
    txt = Text1
    dy = prnt(X, Y, fnt, txt0)
    X = 2500
    txt = Text2
    dy = prnt(X, Y, fnt, txt0)
    X = 4000
    txt = Text3
    dy = prnt(X, Y, fnt, txt0)
      

  5.   

    对不起,代码修改如下:Option Explicit
    Private X As Integer
    Private Y As Integer
    Private fnt As Integer
    Private txt As Variant
    Private dy As Variant
    Private dd As VariantPublic Function prnt(X As Variant, Y As Variant, fnt As Variant, txt As Variant)
    Printer.CurrentX = X
    Printer.CurrentY = Y
    Printer.FontSize = fnt
    Printer.Print txt
    End FunctionPrivate Sub numDataPrint1_Click()
    Y = 450
    X = 1000
    txt = Text1
    dy = prnt(X, Y, fnt, txt)
    X = 2500
    txt = Text2
    dy = prnt(X, Y, fnt, txt)
    X = 4000
    txt = Text3
    dy = prnt(X, Y, fnt, txt)
    End Sub
    Printer.EndDoc
      

  6.   

    对不起,代码修改如下:Option Explicit
    Private X As Integer
    Private Y As Integer
    Private fnt As Integer
    Private txt As Variant
    Private dy As Variant
    Private dd As VariantPublic Function prnt(X As Variant, Y As Variant, fnt As Variant, txt As Variant)
    Printer.CurrentX = X
    Printer.CurrentY = Y
    Printer.FontSize = fnt
    Printer.Print txt
    End FunctionPrivate Sub numDataPrint1_Click()
    Y = 450
    X = 1000
    txt = Text1
    dy = prnt(X, Y, fnt, txt)
    X = 2500
    txt = Text2
    dy = prnt(X, Y, fnt, txt)
    X = 4000
    txt = Text3
    dy = prnt(X, Y, fnt, txt)
    Printer.EndDoc
    End Sub
      

  7.   

    用excel打印,先引用
      Dim i As Integer 
      Dim j As Integer 
      Dim xlApp As Excel.Application 
      Dim xlBook As Excel.Workbook 
      Dim xlSheet As Excel.Worksheet 
      Set xlApp = CreateObject("Excel.Application") 
      xlApp.Visible = True 
      Set xlBook = xlApp.Workbooks.Add 
      Set xlSheet = xlBook.Worksheets(1) 
      xlSheet.Cells(6, 1) = "i" 
      For i = 0 To gridrow 
       grid1.Row = i 
       For j = 0 To 6 
       Grid1.Col = j 
       If IsNull(Grid1.Text) = False Then 
      xlSheet.Cells(i + 5, j + 1) = Grid1.Text 
       End If 
       Next j 
      Next i 
    End Sub 
      

  8.   

    先创建一个 .TXT,空文件,
    然后,把六个数据写入.后打印
      

  9.   

    “所见即所得”打印,需要两个 Picture 控件,其中一个作为容器放置 TextBox 或 Label 等控件。另一个用于生成打印图像:   Picture1.SetFocus
       Picture2.AutoRedraw = True
       rv = SendMessage(Picture1.hwnd, WM_PAINT, Picture2.hDC, 0)
       rv = SendMessage(Picture1.hwnd, WM_PRINT, Picture2.hDC, PRF_CHILDREN + PRF_CLIENT + PRF_OWNED)
       Picture2.Picture = Picture2.Image
       Picture2.AutoRedraw = False   Printer.Print ""
       Printer.PaintPicture Picture2.Picture, 0, 0
       Printer.EndDoc
      

  10.   

    改变X Y fnt txt等的赋值内容可按要求实现打印
    Private Y As Integer
    Private fnt As Integer
    Private txt As Variant
    Private dy As Variant
    Private dd As VariantPublic Function prnt(X As Variant, Y As Variant, fnt As Variant, txt As Variant)
    Printer.CurrentX = X
    Printer.CurrentY = Y
    Printer.FontSize = fnt
    Printer.Print txt
    End FunctionPrivate Sub DataPrint1_Click()
    fnt = 16
    Y = 450
    X = 1000
    txt = Text1
    dy = prnt(X, Y, fnt, txt)
    Y = 1450
    X = 1000
    txt = Text2
    dy = prnt(X, Y, fnt, txt)
    Y = 2450
    X = 2500
    txt = Text3
    dy = prnt(X, Y, fnt, txt)
    fnt = 12
    Y = 450
    X = 2500
    txt = Text1
    dy = prnt(X, Y, fnt, txt)
    Y = 1450
    X = 4000
    txt = Text2
    dy = prnt(X, Y, fnt, txt)
    Y = 2450
    X = 4000
    txt = Text3
    dy = prnt(X, Y, fnt, txt)
    Printer.EndDoc
    End Sub
      

  11.   

    Private Sub DataPrint1_Click()这个是啥按钮啊??这是VB打印需要用的按钮,还是您自己起的名字啊,糊涂中,
      

  12.   

    DataPrint1 是自己起的按钮名字