如何用VB程序对zebra斑马标签打印机打印标签?

signboy 2007-08-22 04:13:35
最好能提供个范例,谢谢,问题解决,再开帖酬谢!
...全文
794 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
mmm1024 2008-11-04
  • 打赏
  • 举报
回复
script.txt文件内容是什么样的阿。

[Quote=引用 4 楼 tqtang 的回复:]
有调过东芝的,但应该都是差不多的。
sBuf = "{PV01;1020,0190,0020,0030,B,00,B|} "
.Output = sBuf

sCheckValue = Left( "qty: " & Space(20), 17)

sBuf = "{RV01; " & sCheckValue & sBundle & "|} "
.Output = sBuf


sBuf = "{XB01;1020,0195,3,1,01,0…
[/Quote]
lonet 2008-09-01
  • 打赏
  • 举报
回复
标签打印机都有自己的控制语言,直接把它的控制语言往并口发就可以了!其中中文打印与状态检测是难点。中文打印他应该会提供一个Dll给你调用或者直接在机器的固化字库。并口状态检测我到现在也没有很好的解决方法!
xbuddy 2008-08-31
  • 打赏
  • 举报
回复
VB.net输出数据至Zebra打印机打印条码的程序

Imports System.IO
Imports System.Text

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'判断sn输入是否正确
If Strings.Len(TextBox1.Text) = 11 Then
Else
MsgBox("Incorrect SN , please check again")
TextBox1.Focus()
TextBox1.SelectAll()
Exit Sub
End If


'判断itemcode输入是否正确
If Strings.Len(TextBox3.Text) = 11 Then
ElseIf Strings.Len(TextBox3.Text) = 12 Then
ElseIf Strings.Len(TextBox3.Text) = 14 Then
ElseIf Strings.Len(TextBox3.Text) = 15 Then
Else
MsgBox("Incorrect itemcode , please check again")
TextBox3.Focus()
TextBox3.SelectAll()
Exit Sub
End If

'sn赋值
Dim sn As String = ""
sn = TextBox1.Text

'itemcode赋值
Dim itemcode As String = ""
If Strings.Len(TextBox3.Text) = 15 OrElse Strings.Len(TextBox3.Text) = 12 Then
itemcode = Strings.Left(TextBox3.Text, 7) & Strings.Right(TextBox3.Text, 5)
Else
itemcode = Strings.Left(TextBox3.Text, 7) & Strings.Right(TextBox3.Text, 4)
End If

'根据itemcode判断itemname
Dim itemname As String = ""

If itemcode = "082849A.101" Then
itemname = "FSMB CORE"

ElseIf itemcode = "082849A.102" Then
itemname = "FSMB CORE"

ElseIf itemcode = "082849A.103" Then
itemname = "FSMB CORE"

ElseIf itemcode = "082849A.104" Then
itemname = "FSMB CORE"

ElseIf itemcode = "082849A.105" Then
itemname = "FSMB CORE"

ElseIf itemcode = "083688A.105" Then
itemname = "FRGD CORE"

ElseIf itemcode = "083640A.207" Then
itemname = "FRIB CORE"

ElseIf itemcode = "083689A.101" Then
itemname = "FRGC CORE"

ElseIf itemcode = "083689A.102" Then
itemname = "FRGC CORE"

ElseIf itemcode = "083689A.103" Then
itemname = "FRGC CORE"

ElseIf itemcode = "083689A.104" Then
itemname = "FRGC CORE"

ElseIf itemcode = "083689A.105" Then
itemname = "FRGC CORE"

Else : MsgBox("The itemcode isn't in the database , Please check if input is incorrect or contact with you administrator.")
Exit Sub
End If


'更改数据,发送打印
Dim serr As String = ""
Dim outdata As String
outdata = GetFileContents(WORKING_DIRECTORY_SCRIPT & "\script.txt", serr)
If serr = "" Then
If outdata <> "" Then
outdata = outdata.Replace("$sn$", sn)
outdata = outdata.Replace("$itemcode$", itemcode)
outdata = outdata.Replace("$itemname$", itemname)
Dim file_name As String = WORKING_DIRECTORY_SCRIPT & "\script-temp.txt"
Dim fi As New System.IO.FileInfo(file_name)
SaveTextToFile(outdata, file_name)
CopyFile(file_name, "LPT1", 1)
End If
End If

TextBox3.Clear()
TextBox1.Focus()
TextBox1.SelectAll()

End Sub

'更换数据
Public Const WORKING_DIRECTORY_SCRIPT As String = "C:\users\script"
Private Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long

Public Function printer(Optional ByRef sn As String = "", Optional ByRef itemcode As String = "", Optional ByRef itemname As String = "", Optional ByRef qty As String = "") As Boolean

Dim serr As String = ""
Dim outdata As String
outdata = GetFileContents(WORKING_DIRECTORY_SCRIPT & "\script.txt", serr)
If serr = "" Then
If outdata <> "" Then
outdata = outdata.Replace("$sn$", sn)
outdata = outdata.Replace("$itemcode$", itemcode)
outdata = outdata.Replace("$itemname$", itemname)
Dim file_name As String = WORKING_DIRECTORY_SCRIPT & "\script-temp.txt"
Dim fi As New System.IO.FileInfo(file_name)
SaveTextToFile(outdata, file_name)
CopyFile(file_name, "LPT1", 1)
End If
Return True
End If
Return False
End Function


'读取文件
Public Function GetFileContents(ByVal FullPath As String, Optional ByRef ErrInfo As String = "") As String

Dim strContents As String
Dim objReader As StreamReader
Try
objReader = New StreamReader(FullPath)
strContents = objReader.ReadToEnd()
objReader.Close()
Return strContents
Catch Ex As Exception
ErrInfo = Ex.Message
Return ErrInfo
End Try
End Function

'保存文件
Public Function SaveTextToFile(ByVal strData As String, ByVal FullPath As String, Optional ByVal ErrInfo As String = "") As Boolean

Dim bAns As Boolean = False
Dim objReader As StreamWriter
Try
objReader = New StreamWriter(FullPath)
objReader.Write(strData)
objReader.Close()
bAns = True
Catch Ex As Exception
ErrInfo = Ex.Message
End Try
Return bAns
End Function


'button1获取焦点后自动激发click响应
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.KeyPreview = True

End Sub

Private Sub Form1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
If Button1.Focused = True Then
Me.Button1.PerformClick()
End If
End Sub
'button1获取焦点后自动激发click响应---向上

'以下为设置无标题栏拉动窗体
'注意:要设置form的controlbox属性为false
Dim MousX As Integer
Dim MousY As Integer
Dim CurrX As Integer
Dim CurrY As Integer

Public Sub myMouseDown(ByVal sender As Object, ByVal ex As MouseEventArgs) Handles MyBase.MouseDown
If ex.Button = MouseButtons.Left Then
'如果是鼠标左键,则不捕获鼠标
Me.Capture() = False

'获得鼠标坐标(相对于窗体)
MousX = ex.X
MousY = ex.Y
End If
End Sub

Public Sub myMouseMove(ByVal sender As Object, ByVal ex As MouseEventArgs) Handles MyBase.MouseMove
If ex.Button = MouseButtons.Left Then
'左键操作
CurrX = Me.Left - MousX + ex.X
CurrY = Me.Top - MousY + ex.Y
'设置窗体相对于屏幕的坐标
Me.SetDesktopLocation(CurrX, CurrY)
End If
End Sub
'
Public Sub myMouseUp(ByVal sender As Object, ByVal ex As MouseEventArgs) Handles MyBase.MouseUp
If ex.Button = MouseButtons.Left Then
Me.Capture() = True

End If
End Sub
'以上为设置无标题栏拉动窗体


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
tqtang 2007-08-28
  • 打赏
  • 举报
回复
有调过东芝的,但应该都是差不多的。
sBuf = "{PV01;1020,0190,0020,0030,B,00,B|}"
.Output = sBuf

sCheckValue = Left("qty: " & Space(20), 17)

sBuf = "{RV01;" & sCheckValue & sBundle & "|}"
.Output = sBuf


sBuf = "{XB01;1020,0195,3,1,01,01,03,03,02,0,0030|}"
.Output = sBuf
sBuf = "{RB01;" & sBundle & "|}"
.Output = sBuf
VBAdvisor 2007-08-26
  • 打赏
  • 举报
回复
zebra斑马标签打印机打印标签

Google "VB Label Printer"
deakal 2007-08-22
  • 打赏
  • 举报
回复
——先培训 就业后 分期还款——
试听,是了解IT机构师资,环境以及教学质量的重要环节。清软国际软件培训“让有志于编程的人能够以编程为事业,让喜欢编程的人能够享受编程”企业文化理念,在学员培训即将结束时,我们还会有专业的指导老师为您做职业规划,并为您推荐工作单位,最终实现就业梦想.而且在以后的工作中遇到一些问题还可以联系您们的老师一起探讨研究!

  在教学上,我们的授课老师都是在业内有相当知名度的培训专家,他们不仅有丰富的理论知识,还拥有多年开发大型项目的实际工作经验,大家知道,这两个条件是必须具备的两者缺一不可.多年工作经验使他们深知,如果学员只掌握书本上的理论知识,而不能动手,那将毫无用处.所以他们将把带领学生做项目开发当成重中之重,实践证明:只有这样,教出来的学生才能很快适应工作的需要,到了企业才能上手并承担开发项目。
清软国际IT培训将引领IT技术爱好者步入软件王国,让您在求职或工作中技压群雄,顺利步入高薪外企的殿堂,成就您与众不同的辉煌人生!


挑战程序员,挑战项目经理,挑战自我!!!

地点:北京市海淀区中关村东路18号财智国际大厦2层
电话:010-82601066 010-82601062
网址:www.sinojava.com
clear_zero 2007-08-22
  • 打赏
  • 举报
回复
你的zebra不是有说明么,你本身有font按照说明写代码就好

不难

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧