我想用在VB6里嵌水晶报表,实现超市小票的打印功能,请问如何实现?一般报表都是用b5或A4等纸张类型,在作报表时先设定纸张,再做就可以了。但超市里的小票是带状的,且客户的购买量不同,即每次打印的长度不同,请问这个怎么实现?请大家帮忙指点

解决方案 »

  1.   

    这种情况应该是有特殊的打印机的吧,既然不是普通的打印机,应该不能用普通的办法打印吧.我没试过,关注ing
      

  2.   

    不要用报表,应该直接打开打印机端口,往里面写就行了.我以前做过POS系统.
    EPSON-PD210 打印机有带一个指令集.
     Open "LPT1" For Output As #1
          Print #1, Chr$(27); "@" '初始化打印机
          Print #1, Chr$(28); "&"
          Print #1, Chr$(&H1B); "K"; Chr(48) '退纸
          Print #1, Chr$(&H1B); "K"; Chr(48)
          Print #1, Chr$(&H1B); "K"; Chr(48)
          Print #1, Chr$(&H1B); "K"; Chr(48)
         
        '开钱箱
         Print #1, Chr$(&H1B); "p"; Chr$(0); Chr$(25); Chr$(250)
        '由于此处会进纸,故倒退再打
       
         Print #1, Chr$(28); "!"; Chr(0)
      
        Dim myText As String
        Dim Len1 As Integer, Len2 As Integer, Len3 As Integer, Len4 As Integer, LenTmp As Integer
        Dim amount As String, price As String, total As String
     
        With rsTable21
            If .RecordCount > 0 Then
                .MoveFirst
                Do While Not .EOF
                    Len1 = Len(Left(.Fields("owncode").Value, 20))
                    amount = IIf(CSng(.Fields("Amount").Value) > 1, Format(.Fields("Amount").Value, "#########0.00"), "0" & .Fields("Amount").Value)
                    Len2 = Len(amount)
                    price = Format(.Fields("price").Value, "#########0.00")
                    Len3 = Len(price)
                    total = IIf(CSng(.Fields("total").Value) > 1, Format(.Fields("total").Value, "#########0.00"), "0" & CStr(.Fields("total").Value))
                    Len4 = Len(total)
                    LenTmp = Len1 + Len2
                    myText = ""
                       myText = Left(.Fields("owncode").Value, 20) & Space(22 - LenTmp) & amount                myText = myText & Space(8 - Len3) & price
                    myText = myText & Space(8 - Len4) & total
                    Print #1, myText
                    myText = ""
                    Len1 = Len(.Fields("GoodName").Value)
                    Len2 = Len(.Fields("unit").Value)
                    LenTmp = Len1 * 2 + Len2                  myText = Left(.Fields("GoodName").Value, 20) & "(" & .Fields("unit").Value & ")" & "  折扣:" & Format(.Fields("ratio").Value, "#########0.00")
                      Print #1, myText
                    .MoveNext
                Loop
            End If
        End With
        Print #1, Space(33 - Len(txt_PlanTotal.Text)) & "合计:" & IIf(CSng(txt_PlanTotal.Text) > 1, txt_PlanTotal.Text, "0" & txt_PlanTotal.Text)
        Print #1, Space(33 - Len(txt_ActTotal.Text)) & "现金:" & IIf(CSng(txt_ActTotal.Text) > 1, txt_ActTotal.Text, "0" & txt_ActTotal.Text)
        Print #1, Space(31 - Len(txt_TheChange.Text)) & "找回:" & IIf(CSng(txt_TheChange.Text) > 1, txt_TheChange.Text, "0" & txt_TheChange.Text)
       
        Print #1, "流水号:" & txt_Menuid.Text & "  " & Date & " " & Time
        Print #1, "谢谢惠顾 欢迎再来"
      Print #1, Chr(13)
          
        Print #1, "欢迎光临便利店 " & JoinID '置后
       Print #1, "收银员:" & theHrName & "              机号:" & Mid(Trim(MachinNum), 1, Len(Trim(MachinNum)))
         Dim titles As String
         titles = "货号               数量    单价    金额"
          Print #1, titles
             
        Close #1