 |
|
ขอวิธีสั่งพิมพ์บาร์โค้ด EAN13 แปลงจากบาร์โค้ดเป็น String เพื่อเตรียมปริ้นบาร์โค้ดนะครับ |
|
 |
|
|
 |
 |
|
http://www.codeproject.com/Articles/10162/Creating-EAN-13-Barcodes-with-C
ลองดูบทตวามนี้ครับ เผื่อช่วยอะไรได้
|
 |
 |
 |
 |
Date :
2014-01-18 22:02:20 |
By :
fhackman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ สำหรับข้อมูล เข้าไปดูมาแล้วครับ แต่ยังไม่เข้าใจ T_T
อยากทำได้แค่ แปลงตัวบาร์โค้ด 978020113447 เป็น 9HSKCKB*bdeehg+
รบกวนด้วยคร๊าบ ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2014-01-19 20:21:42 |
By :
iArt |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim CodeClair As String = "001034360548"
CodeClair = CodeClair.PadRight(12, "0"c)
MsgBox(EAN13(CodeClair))
End Sub
Public Function EAN13(ByVal chaine As String) As String
Dim i As Integer
Dim first As Integer
Dim checksum As Integer = 0
Dim CodeBarre As String = ""
Dim tableA As Boolean
If Regex.IsMatch(chaine, "^\d{12}$") Then
For i = 1 To 11 Step 2
System.Diagnostics.Debug.WriteLine(chaine.Substring(i, 1))
checksum += Convert.ToInt32(chaine.Substring(i, 1))
Next
checksum *= 3
For i = 0 To 11 Step 2
checksum += Convert.ToInt32(chaine.Substring(i, 1))
Next
chaine += (10 - checksum Mod 10) Mod 10
CodeBarre = chaine.Substring(0, 1) & ChrW(65 + Convert.ToInt32(chaine.Substring(1, 1)))
first = Convert.ToInt32(chaine.Substring(0, 1))
For i = 2 To 6
tableA = False
Select Case i
Case 2
If first >= 0 AndAlso first <= 3 Then
tableA = True
End If
Exit Select
Case 3
If first = 0 OrElse first = 4 OrElse first = 7 OrElse first = 8 Then
tableA = True
End If
Exit Select
Case 4
If first = 0 OrElse first = 1 OrElse first = 4 OrElse first = 5 OrElse first = 9 Then
tableA = True
End If
Exit Select
Case 5
If first = 0 OrElse first = 2 OrElse first = 5 OrElse first = 6 OrElse first = 7 Then
tableA = True
End If
Exit Select
Case 6
If first = 0 OrElse first = 3 OrElse first = 6 OrElse first = 8 OrElse first = 9 Then
tableA = True
End If
Exit Select
End Select
If tableA Then
CodeBarre += ChrW(65 + Convert.ToInt32(chaine.Substring(i, 1)))
Else
CodeBarre += ChrW(75 + Convert.ToInt32(chaine.Substring(i, 1)))
End If
Next
CodeBarre += "*"
'Ajout s้parateur central / Add middle separator
For i = 7 To 12
CodeBarre += ChrW(97 + Convert.ToInt32(chaine.Substring(i, 1))) <<<<< Error บันทัดนี้นะครับ
Next
CodeBarre += "+"
End If
Return CodeBarre
End Function
Error :
Index and length must refer to a location within the string.
Parameter name: length
ช่วยดูโค้ดหน่อยนะครับ ว่าผิดตรงไหน
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2014-01-21 11:40:09 |
By :
iArt |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำได้แล้วคร๊าบบบบบ ฮ่าๆๆ
|
 |
 |
 |
 |
Date :
2014-01-21 19:20:38 |
By :
iArt |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้ยังไงหรอครับ ขอความรู้หน่อย
|
 |
 |
 |
 |
Date :
2014-01-22 14:41:58 |
By :
Agility |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Public Function EAN13(ByVal chaine As String) As String
Dim i As Integer
Dim first As Integer
Dim checksum As Integer = 0
Dim CodeBarre As String = ""
Dim tableA As Boolean
If Microsoft.VisualBasic.Len(chaine) = 12 Then
If Convert.ToInt64(chaine) >= 100000000000 Then
For i = 1 To 11 Step 2
System.Diagnostics.Debug.WriteLine(chaine.Substring(i, 1))
checksum += Convert.ToInt32(chaine.Substring(i, 1))
Next
checksum *= 3
For i = 0 To 11 Step 2
checksum += Convert.ToInt32(chaine.Substring(i, 1))
Next
chaine = chaine & (10 - checksum Mod 10) Mod 10
CodeBarre = chaine.Substring(0, 1) & ChrW(65 + Convert.ToInt32(chaine.Substring(1, 1)))
first = Convert.ToInt32(chaine.Substring(0, 1))
For i = 2 To 6
tableA = False
Select Case i
Case 2
If first >= 0 AndAlso first <= 3 Then
tableA = True
End If
Exit Select
Case 3
If first = 0 OrElse first = 4 OrElse first = 7 OrElse first = 8 Then
tableA = True
End If
Exit Select
Case 4
If first = 0 OrElse first = 1 OrElse first = 4 OrElse first = 5 OrElse first = 9 Then
tableA = True
End If
Exit Select
Case 5
If first = 0 OrElse first = 2 OrElse first = 5 OrElse first = 6 OrElse first = 7 Then
tableA = True
End If
Exit Select
Case 6
If first = 0 OrElse first = 3 OrElse first = 6 OrElse first = 8 OrElse first = 9 Then
tableA = True
End If
Exit Select
End Select
MsgBox(Convert.ToInt32(chaine.Substring(i, 1)))
If tableA Then
CodeBarre += ChrW(65 + Convert.ToInt32(chaine.Substring(i, 1)))
Else
CodeBarre += ChrW(75 + Convert.ToInt32(chaine.Substring(i, 1)))
End If
Next
CodeBarre += "*"
For i = 7 To 12
CodeBarre += ChrW(97 + Convert.ToInt32(chaine.Substring(i, 1)))
Next
CodeBarre += "+"
End If
End If
Return CodeBarre
End Function
|
 |
 |
 |
 |
Date :
2017-01-09 13:35:34 |
By :
mm3102 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|