프로그램 소스/VB.NET

[VB.NET] 간단한 영수증 출력 예제소스

프로젝트빈 2020. 11. 29. 12:00
반응형

VB.NET 간단한 영수증 출력 예제소스

 

프로그램 사진1)

 

 

■ 예제소스

Public WithEvents A_PORT As New System.IO.Ports.SerialPort

Private Sub B_OPEN_Click(sender As Object, e As EventArgs) Handles B_OPEN.Click
        Try
            A_PORT.PortName = C_PORT.Text
            A_PORT.BaudRate = C_비트.Text
            A_PORT.Parity = IO.Ports.Parity.None
            A_PORT.DataBits = C_데이터비트.Text 
            A_PORT.StopBits = IO.Ports.StopBits.One
            A_PORT.Encoding = System.Text.Encoding.Default
            A_PORT.ReadTimeout = 1000
            A_PORT.WriteTimeout = 2000

            If A_PORT.IsOpen = True Then A_PORT.Close()
            A_PORT.Open()

            B_OPEN.Enabled = False
            B_Close.Enabled = True
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
    
    Private Sub B_Close_Click(sender As Object, e As EventArgs) Handles B_Close.Click
        Try
            A_PORT.Close()
            B_OPEN.Enabled = True
            B_Close.Enabled = False
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
    
    Private Sub B_테스트출력_Click(sender As Object, e As EventArgs) Handles B_테스트출력.Click
        영수증출력()
    End Sub
    
    Public Sub 영수증출력()
        Dim W_STR As String
        Dim strCenter As String
        Dim strLeft As String
        Dim strDouble As String
        Dim strNormal As String
        strCenter = Chr(&H1B) & Chr(&H61) & Chr(&H31)
        strLeft = Chr(&H1B) & Chr(&H61) & Chr(&H30)
        strDouble = Chr(&H1B) & Chr(&H21) & Chr(&H20)
        strNormal = Chr(&H1B) & Chr(&H21) & Chr(&H2)

        W_STR = strLeft
        A_PORT.WriteLine(W_STR)

        W_STR = strDouble    //글자 크게
        A_PORT.WriteLine(W_STR)

        W_STR = "테스트1"
        A_PORT.WriteLine(W_STR)

        W_STR = Chr(&H1B) & Chr(&H21) & Chr(&H0) //확대해제
        A_PORT.WriteLine(W_STR)

        W_STR = "테스트2"
        A_PORT.WriteLine(W_STR)

        W_STR = "테스트3"
        A_PORT.WriteLine(W_STR)

        W_STR = "테스트4"
        A_PORT.WriteLine(W_STR)

        W_STR = "테스트5"
        A_PORT.WriteLine(W_STR)

        W_STR = "테스트6"
        A_PORT.WriteLine(W_STR)

        W_STR = Chr(&H1B) & "i"  //full cutting
        A_PORT.WriteLine(W_STR)

    End Sub
    
    
    

 

 

 

반응형