📄 mainform.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Mainform
BorderStyle = 0 'None
Caption = "打印演示程序V1.0"
ClientHeight = 3195
ClientLeft = 105
ClientTop = 105
ClientWidth = 4185
FillColor = &H80000012&
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00800000&
Icon = "Mainform.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3195
ScaleWidth = 4185
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin MSCommLib.MSComm MSComm1
Left = 3645
Top = 2520
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.CommandButton Command4
BackColor = &H00000000&
Caption = "关闭软件"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 2340
TabIndex = 3
Top = 2070
Width = 1365
End
Begin VB.CommandButton Command3
Caption = "演示打印"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 405
TabIndex = 2
Top = 2070
Width = 1365
End
Begin VB.CommandButton Disconnect
Caption = "断开打印机"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 660
Left = 2295
TabIndex = 1
Top = 945
Width = 1380
End
Begin VB.CommandButton Connect
Caption = "连接打印机"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 660
Left = 405
TabIndex = 0
Top = 945
Width = 1365
End
Begin VB.Label Label1
Caption = "POS2000 VisulBasic程序"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 450
Left = 360
TabIndex = 4
Top = 225
Width = 3585
End
Begin VB.Menu PORTSET
Caption = "端口选择(&X)"
Begin VB.Menu mnuSerialPort
Caption = "串型端口(&S)"
End
Begin VB.Menu mnuParralelPort
Caption = "并行端口(&P)"
End
End
Begin VB.Menu mnuHelp
Caption = "帮助(&H)"
Begin VB.Menu mnuAbout
Caption = "关于(&A)"
End
End
End
Attribute VB_Name = "Mainform"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private ival As Integer
Private Sub Command3_Click()
Dim i As Integer
ival = Val(InputBox("Input the Num of tickets: ", "DEMOPOS2K", 1))
If ival > 0 And ival < 100 Then
'begin print page
'''''''进入黑标模式a=2 cutting posintion.
'''''''a=1 printing posintion
MSComm1.Output = Chr$(29) + "(" + "F" + Chr$(4) + Chr$(0) + Chr$(2) + Chr$(0) + Chr$(79) + Chr$(0) ''''a=2
MSComm1.Output = Chr$(29) + "(" + "F" + Chr$(4) + Chr$(0) + Chr$(1) + Chr$(0) + Chr$(192) + Chr$(0) ''''a=1
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
For i = 1 To ival
''''设置切撕纸位置到黑标的距离为8mm
''''起始打印位置距切撕纸位置距离为11mm
'''''begin page printing
MSComm1.Output = Chr$(29) + Chr$(12) 'a=1
MSComm1.Output = Chr$(28) + Chr$(38) 'FS &进入汉字模式
''''''''''''font B
MSComm1.Output = Chr$(&H1B) + "!" + Chr$(&H1)
MSComm1.Output = Chr$(28) + Chr$(87) + Chr$(1) '''''''FS W n=1
MSComm1.Output = " 北京公达集团公司" + Chr$(10)
MSComm1.Output = Chr$(28) + Chr$(87) + Chr$(0) ''''''''FS W n=0
MSComm1.Output = Chr$(28) + Chr$(33) + Chr$(12) ''''''FS ! n=12
MSComm1.Output = " 蛇口广华电子技术公司" + Chr$(10) + Chr$(10)
MSComm1.Output = Chr$(28) + Chr$(33) + Chr$(4) '''''FS ! n=4倍宽
MSComm1.Output = " 电话:0086-755-6821550" + Chr$(10)
MSComm1.Output = " 传真:0086-755-6695756" + Chr$(10) + Chr$(10)
MSComm1.Output = Chr$(28) + Chr$(33) + Chr$(8) ''''''FS ! n=8倍高
MSComm1.Output = Chr$(27) + "!" + Chr$(16) '''''''''ESC ! n=16倍高
MSComm1.Output = " TP POS2000针式打印机" + Chr$(10)
MSComm1.Output = Chr$(28) + "!" + Chr$(0)
MSComm1.Output = Chr$(27) + "!" + Chr$(0)
MSComm1.Output = "采用EPSON M-U110的针式打印机构" + Chr$(10)
MSComm1.Output = "打印方法:九针列式双向打印" + Chr$(10)
MSComm1.Output = "打印速度:约3.5行/秒(双向打印ASCII字符)" + Chr$(10)
MSComm1.Output = "走纸速度:约100mm/秒" + Chr$(10)
MSComm1.Output = "黑标检测:黑标印在票据正面左边,黑标长度(走纸方向)5mm,宽度最小12mm" + Chr$(10)
MSComm1.Output = "软件功能:能实现中西文同行混打;纸尽,暂停打印,上纸后继续打印,黑标定位打印" + Chr$(10)
MSComm1.Output = "打印机可靠性:500万行(MCBF)" + Chr$(10) + Chr$(10)
MSComm1.Output = Chr$(28) + Chr$(46) '''''''''FS .退出汉字模式
MSComm1.Output = Chr$(27) + "!" + Chr$(1) '设置字模7*7 ESC !n=17,33,49'
MSComm1.Output = "HHHHHHHHHHHHHHHHHHHH" + Chr$(10)
MSComm1.Output = Chr$(27) + "!" + Chr$(17)
MSComm1.Output = "HHHHHHHHHHHHHHHHHHHH" + Chr$(10)
MSComm1.Output = Chr$(27) + "!" + Chr$(33)
MSComm1.Output = "HHHHHHHHHHHHHHHHHHHH" + Chr$(10)
MSComm1.Output = Chr$(27) + "!" + Chr$(49)
MSComm1.Output = "HHHHHHHHHHHHHHHHHHHH" + Chr$(10)
MSComm1.Output = Chr$(29) + Chr$(86) + Chr$(66) + Chr$(0)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'MSComm1.Output = Chr$(29) + "V" + Chr$(1) 'a=2
Next i
'Sleep (500)
Else
MsgBox ("input error")
End If
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Connect_Click()
'''''''connet the serial port
MSComm1.CommPort = Setport.igSelectPort
MSComm1.Settings = Setport.strgSetPort ' 波特,无奇偶校验,8 位数据,一个停止位。
MSComm1.OutBufferSize = 1024 ' 32 byte is the Limit.
MSComm1.InBufferSize = 512
MSComm1.RThreshold = 1
MSComm1.SThreshold = 1
MSComm1.InputLen = 1
MSComm1.Handshaking = Setport.igFlowControl ' Set handshaking
MSComm1.PortOpen = True
MSComm1.OutBufferCount = 0 ' clear the output buffer
MSComm1.InBufferCount = 0 'clear the input buffer
Connect.Enabled = False
Disconnect.Enabled = True
Command3.Enabled = True
End Sub
Private Sub Disconnect_Click()
''''''' disconnect the serial port
MSComm1.OutBufferCount = 0 ' clear the output buffer
MSComm1.InBufferCount = 0 'clear the input buffer
MSComm1.PortOpen = False
Disconnect.Enabled = False
Connect.Enabled = True
Command3.Enabled = False
mnuParralelPort.Enabled = True
End Sub
Private Sub Form_Load()
''''''''''''''''''
''''''''''''''''''''defaut port set
'''''for use serial port
'GoTo useparallelport '''igore when using serial port.
Setport.igSelectPort = igCom1
Setport.strgSetPort = "9600,N,8,1"
Setport.igFlowControl = comRTS
Disconnect.Enabled = False
Command3.Enabled = False
End Sub
Private Sub mnuAbout_Click()
''''版本信息
Dim About As String
About = MsgBox(vbCrLf & "北京公达电子有限责任公司" & vbCrLf & vbCrLf & " 打印演示程序Ver1.0" & vbCrLf & vbCrLf & " 软件编制:戴建国" & vbCrLf & vbCrLf & "联系方式:Support@grandtp.com", 64)
End Sub
Private Sub mnuExit_Click()
End
End Sub
Private Sub mnuParralelPort_Click()
'' load parralelport
ParralelPort.Show vbModal
End Sub
Private Sub mnuSerialPort_Click()
''Load SerialPort
SerialPort.Show vbModal
mnuParralelPort.Enabled = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -