Membuat Barcode menggunakan VB.NET

Tutorial Belajar VB.Net Khusus pemula : cara membuat Barcode menggunakan Vb.NET, aplikasi barcode sederhana menggunakan vb.net EAN 8 dan EAN 13, tutorial lengkap vb.net di sector code

Cara membuat aplikasi sederhana Barcode VB.NET - dengan bahasa pemrograman Vb.Net kita juga bisa membuat aplikasi untuk mencetak Barcode yang biasanya digunakan dalam apikasi inventory penjualan misalnya. Tutorial Sector Code sebelumnya sudah pernah membahas tentang cara pembuatan Barcode menggunakan bahasa pemrograman PHP, silahkan baca Cara membuat Barcode menggunakan PHP, SImak terus ya cara pembuatan aplikasi Barcode dengan VB.NET ini, berikut penampakan aplikasi barcode sederhana :
Aplikasi Barcode Sederhana

Apliaksi Barcode VB.NET

Langsung saja pembuatannya, silahkan buka visual studio 2010, 2012 atau 2013 dan 2015 kamu dan buatlah project baru dengan nama "AplikasiBarcode". serta desainlah tampilan aplikasinya seperti tampilan dibawah ini :
Membuat Barcode menggunakan VB.NET
Penjelasan :
Component dalam pembuatan aplikasi diatas adalah : GroupBox, PictureBox, Button, dan TextBox serta label,

Membuat Functions Barcode VB.NET

buatlah sebuah modeule baru dengan nama "MdlBarcode.Vb" dan ikuti langkahberikut.

Membuat Functions :
    Private Function Barcode1(ByVal _
    strBarcode As String) As String

        Dim _iNt As Integer
        Dim _StrBil As String
        Dim _StrEx As String
        Dim _StrCode As String

        strBarcode = Trim(strBarcode)
        _StrBil = strBarcode
        If (_StrBil.Length <> 13) And _
        (_StrBil.Length <> 8) Then

            Err.Raise(5, "EAN2Bin", "Invalid EAN Code")
        End If
        For _iNt = 0 To strBarcode.Length - 1
            Select Case (_StrBil.Chars(_iNt).ToString)
                Case Is < "0", Is > "9"
                    Err.Raise(5, "EAN2Bin", _
                    "Invalid char on EAN Code")
            End Select
        Next
        If (_StrBil.Length = 13) Then
            _StrBil = Mid(_StrBil, 2)
            Select Case CInt(Left(strBarcode, 1))
                Case 0
                    _StrCode = "000000"
                Case 1
                    _StrCode = "001011"
                Case 2
                    _StrCode = "001101"
                Case 3
                    _StrCode = "001110"
                Case 4
                    _StrCode = "010011"
                Case 5
                    _StrCode = "011001"
                Case 6
                    _StrCode = "011100"
                Case 7
                    _StrCode = "010101"
                Case 8
                    _StrCode = "010110"
                Case 9
                    _StrCode = "011010"
            End Select
        Else
            _StrCode = "0000"
        End If
        _StrEx = "000101"

        For _iNt = 1 To Len(_StrBil) \ 2
            Select Case CInt(Mid(_StrBil, _iNt, 1))
                Case 0
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0001101", "0100111")
                Case 1
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0011001", "0110011")
                Case 2
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0010011", "0011011")
                Case 3
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0111101", "0100001")
                Case 4
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0100011", "0011101")
                Case 5
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0110001", "0111001")
                Case 6
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0101111", "0000101")
                Case 7
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0111011", "0010001")
                Case 8
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0110111", "0001001")
                Case 9
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0001011", "0010111")
            End Select
        Next _iNt
        _StrEx &= "01010"

        For _iNt = Len(_StrBil) \ 2 + 1 To Len(_StrBil)
            Select Case CInt(Mid(_StrBil, _iNt, 1))
                Case 0
                    _StrEx &= "1110010"
                Case 1
                    _StrEx &= "1100110"
                Case 2
                    _StrEx &= "1101100"
                Case 3
                    _StrEx &= "1000010"
                Case 4
                    _StrEx &= "1011100"
                Case 5
                    _StrEx &= "1001110"
                Case 6
                    _StrEx &= "1010000"
                Case 7
                    _StrEx &= "1000100"
                Case 8
                    _StrEx &= "1001000"
                Case 9
                    _StrEx &= "1110100"
            End Select
        Next _iNt

        _StrEx &= "101000"
        Barcode1 = _StrEx
    End Function
Berikut Sub COde untuk menampilkan barcode :
    Public Sub PrintBarcode2(ByVal _
    _StrbarCode2 As String, _
    ByVal Gambar As PictureBox, _
    Optional ByVal _x1 As Single = (-1), _
    Optional ByVal _y1 As Single = (-1), _
    Optional ByVal _x2 As Single = (-1), _
    Optional ByVal _y2 As Single = (-1), _
    Optional ByVal _f As Font = Nothing)

        Dim _a As Single
        Dim _posX As Single
        Dim _posY As Single
        Dim _sX As Single
        Dim _StrCode As String
        Dim _StrFormat As New StringFormat()

        _StrCode = Barcode1(_StrbarCode2)
        If (_f Is Nothing) Then
            _f = New Font("Courier New", 10)
        End If

        If _x1 = (-1) Then _x1 = 0
        If _y1 = (-1) Then _y1 = 0
        If _x2 = (-1) Then _x2 = Gambar.Width
        If _y2 = (-1) Then _y2 = Gambar.Height

        _posX = _x1
        _posY = _y2 - CSng(1.5 * _f.Height)

        Gambar.CreateGraphics.FillRectangle(New  _
        System.Drawing.SolidBrush(Gambar.BackColor), _
        _x1, _y1, _x2 - _x1, _y2 - _y1)
        _sX = (_x2 - _x1) / _StrCode.Length

        For _a = 1 To Len(_StrCode)
            If Mid(_StrCode, _a, 1) = "1" Then
                Gambar.CreateGraphics.FillRectangle(New  _
                System.Drawing.SolidBrush(Gambar.ForeColor), _
                _posX, _y1, _sX, _posY)
            End If
            _posX = _x1 + (_a * _sX)
        Next _a

        _StrFormat.Alignment = StringAlignment.Center
        _StrFormat.FormatFlags = StringFormatFlags.NoWrap
        Gambar.CreateGraphics.DrawString( _
        _StrbarCode2, _f, New System.Drawing.SolidBrush(Gambar.ForeColor), _
        CSng((_x2 - _x1) / 2), CSng(_y2 - _f.Height), _StrFormat)

    End Sub
Untuk code Module Barcode selengkapnya :
Option Explicit On 
Imports System.Drawing
Module BarCodeFunctions
    Private Function Barcode1(ByVal _
    strBarcode As String) As String

        Dim _iNt As Integer
        Dim _StrBil As String
        Dim _StrEx As String
        Dim _StrCode As String

        strBarcode = Trim(strBarcode)
        _StrBil = strBarcode
        If (_StrBil.Length <> 13) And _
        (_StrBil.Length <> 8) Then

            Err.Raise(5, "EAN2Bin", "Invalid EAN Code")
        End If
        For _iNt = 0 To strBarcode.Length - 1
            Select Case (_StrBil.Chars(_iNt).ToString)
                Case Is < "0", Is > "9"
                    Err.Raise(5, "EAN2Bin", _
                    "Invalid char on EAN Code")
            End Select
        Next
        If (_StrBil.Length = 13) Then
            _StrBil = Mid(_StrBil, 2)
            Select Case CInt(Left(strBarcode, 1))
                Case 0
                    _StrCode = "000000"
                Case 1
                    _StrCode = "001011"
                Case 2
                    _StrCode = "001101"
                Case 3
                    _StrCode = "001110"
                Case 4
                    _StrCode = "010011"
                Case 5
                    _StrCode = "011001"
                Case 6
                    _StrCode = "011100"
                Case 7
                    _StrCode = "010101"
                Case 8
                    _StrCode = "010110"
                Case 9
                    _StrCode = "011010"
            End Select
        Else
            _StrCode = "0000"
        End If
        _StrEx = "000101"

        For _iNt = 1 To Len(_StrBil) \ 2
            Select Case CInt(Mid(_StrBil, _iNt, 1))
                Case 0
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0001101", "0100111")
                Case 1
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0011001", "0110011")
                Case 2
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0010011", "0011011")
                Case 3
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0111101", "0100001")
                Case 4
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0100011", "0011101")
                Case 5
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0110001", "0111001")
                Case 6
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0101111", "0000101")
                Case 7
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0111011", "0010001")
                Case 8
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0110111", "0001001")
                Case 9
                    _StrEx &= IIf(Mid(_StrCode, _iNt, 1) = _
                    "0", "0001011", "0010111")
            End Select
        Next _iNt
        _StrEx &= "01010"

        For _iNt = Len(_StrBil) \ 2 + 1 To Len(_StrBil)
            Select Case CInt(Mid(_StrBil, _iNt, 1))
                Case 0
                    _StrEx &= "1110010"
                Case 1
                    _StrEx &= "1100110"
                Case 2
                    _StrEx &= "1101100"
                Case 3
                    _StrEx &= "1000010"
                Case 4
                    _StrEx &= "1011100"
                Case 5
                    _StrEx &= "1001110"
                Case 6
                    _StrEx &= "1010000"
                Case 7
                    _StrEx &= "1000100"
                Case 8
                    _StrEx &= "1001000"
                Case 9
                    _StrEx &= "1110100"
            End Select
        Next _iNt

        _StrEx &= "101000"
        Barcode1 = _StrEx
    End Function

    Public Sub PrintBarcode2(ByVal _
    _StrbarCode2 As String, _
    ByVal Gambar As PictureBox, _
    Optional ByVal _x1 As Single = (-1), _
    Optional ByVal _y1 As Single = (-1), _
    Optional ByVal _x2 As Single = (-1), _
    Optional ByVal _y2 As Single = (-1), _
    Optional ByVal _f As Font = Nothing)

        Dim _a As Single
        Dim _posX As Single
        Dim _posY As Single
        Dim _sX As Single
        Dim _StrCode As String
        Dim _StrFormat As New StringFormat()

        _StrCode = Barcode1(_StrbarCode2)
        If (_f Is Nothing) Then
            _f = New Font("Courier New", 10)
        End If

        If _x1 = (-1) Then _x1 = 0
        If _y1 = (-1) Then _y1 = 0
        If _x2 = (-1) Then _x2 = Gambar.Width
        If _y2 = (-1) Then _y2 = Gambar.Height

        _posX = _x1
        _posY = _y2 - CSng(1.5 * _f.Height)

        Gambar.CreateGraphics.FillRectangle(New  _
        System.Drawing.SolidBrush(Gambar.BackColor), _
        _x1, _y1, _x2 - _x1, _y2 - _y1)
        _sX = (_x2 - _x1) / _StrCode.Length

        For _a = 1 To Len(_StrCode)
            If Mid(_StrCode, _a, 1) = "1" Then
                Gambar.CreateGraphics.FillRectangle(New  _
                System.Drawing.SolidBrush(Gambar.ForeColor), _
                _posX, _y1, _sX, _posY)
            End If
            _posX = _x1 + (_a * _sX)
        Next _a

        _StrFormat.Alignment = StringAlignment.Center
        _StrFormat.FormatFlags = StringFormatFlags.NoWrap
        Gambar.CreateGraphics.DrawString( _
        _StrbarCode2, _f, New System.Drawing.SolidBrush(Gambar.ForeColor), _
        CSng((_x2 - _x1) / 2), CSng(_y2 - _f.Height), _StrFormat)

    End Sub
End Module
Selanjutnya pada button Draw di Form Utama tuliskan code berikut untuk memanggil Functions Barcode :
    Private Sub Button1_Click(ByVal sender _
 As System.Object, ByVal e As _
 System.EventArgs) Handles Button1.Click
        Try
            Call PrintBarcode2(Me.TextBox1.Text, _
  Me.PictureBox1, 10, 10, _
  Me.PictureBox1.Width - 20, _
  Me.PictureBox1.Height - 20)
        Catch
            MsgBox(Err.Description, _
     MsgBoxStyle.Exclamation, _
     Application.ProductName)
        End Try

    End Sub
Silahkan bertanya seputar cara pembuatan aplikasi Barcode ini di kotak komentar, dan jangan lupa dishare jika bermanfaat. terima kasih ;)

COMMENTS


Feel free to code it up and send us a pull request.

Hi everyone, let's me know how much this lesson can help your work. Please Subscribe and Follow Our Social Media 'kodeajaib[dot]com' to get Latest tutorials and will be send to your email everyday for free!, Just hit a comment if you have confused. Nice to meet you and Happy coding :) all ^^



Follow by E-Mail


Name

ADO.NET,3,Ajax,6,Android,9,AngularJS,4,ASP.NET,4,Blogger Tutorials,7,Bootstrap,7,C++,1,Codeigniter,2,Cplusplus,6,Crystal Report,6,CSharp,25,Ebook Java,2,FlyExam,1,FSharp,3,Game Development,2,Java,35,JDBC,2,Laravel,89,Lumen,2,MariaDB,2,Ms Access,3,MySQL,31,ODBC,6,OleDB,1,PHP,14,PHP Framework,6,PHP MYSQLI,9,PHP OOP,5,Python,8,Python 3,4,SQL Server,4,SQLite,4,Uncategorized,5,Vb 6,2,Vb.Net,89,Video,48,Vue Js,4,WPF,2,Yii,3,
ltr
item
KODE AJAIB: Membuat Barcode menggunakan VB.NET
Membuat Barcode menggunakan VB.NET
Tutorial Belajar VB.Net Khusus pemula : cara membuat Barcode menggunakan Vb.NET, aplikasi barcode sederhana menggunakan vb.net EAN 8 dan EAN 13, tutorial lengkap vb.net di sector code
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrHAnv4pQBjZV7h0HUna4iil67RSA-kMBRxI_ksFAUzBcqnXN_U6nGmnhF8TPWqeWJPw3nWdEFS3zvEUFAF6mCiD7PBes1JVAic84Uwsl9cn2XX1Dy2sxUFYgqDXezO8HEyjUGKbixE7M/s320/aplikasi-barcode-sederhana.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrHAnv4pQBjZV7h0HUna4iil67RSA-kMBRxI_ksFAUzBcqnXN_U6nGmnhF8TPWqeWJPw3nWdEFS3zvEUFAF6mCiD7PBes1JVAic84Uwsl9cn2XX1Dy2sxUFYgqDXezO8HEyjUGKbixE7M/s72-c/aplikasi-barcode-sederhana.png
KODE AJAIB
https://scqq.blogspot.com/2015/11/membuat-barcode-menggunakan-vbnet.html
https://scqq.blogspot.com/
https://scqq.blogspot.com/
https://scqq.blogspot.com/2015/11/membuat-barcode-menggunakan-vbnet.html
true
3214704946184383982
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy