Public Class BarCodeLibClass
    Private mBarcode As String
    Private BarTextOut As String
    Private BarTextIn As String
    Private BarTextInA As String
    Private BarTextInB As String
    Private TempString As String
    Private BarCodeOut As String
    Private Sum As Long
    Private II As Integer
    Private ThisChar As String
    Private CharValue As Long
    Private CheckSumValue As Integer
    Private CheckSum As String
    Private Subset As Integer
    Private StartChar As String
    Private Weighting As Integer
    Private UCC As Integer


    Public Function Bar128AB(ByVal strCodice As String) As String
        Return Bar128A(strCodice)
    End Function

    Private Property Barcode() As String
        Get
            mBarcode = Bar128A(mBarcode)
            Return mBarcode
        End Get
        Set(ByVal value As String)

            mBarcode = value

        End Set
    End Property

    'Functions in this file:
    ' Bar128A(Text)     -> convert text to bar code 128 subset A
    ' Bar128Aucc(Text)  -> convert text to bar code 128 subset A, UCC/EAN
    ' Bar128B(Text)     -> convert text to bar code 128 subset B
    ' Bar128Bucc(Text)  -> convert text to bar code 128 subset B, UCC/EAN
    ' Bar128C(Text)     -> convert text to bar code 128 subset C
    ' Bar128Cucc(Text)  -> convert text to bar code 128 subset C, UCC/EAN

    ' This function converts a string into a format compatible with Elfring
    ' Fonts Inc bar codes. This conversion is for subset A only. It adds the
    ' start character, scans and converts data, adds a checksum and a stop
    ' character. Note that lower case letters are interpreted as control
    ' characters in subset A!
    '------------------------------------------------------
    Private Function Bar128A(ByVal BarTextInA As String) As String
        Bar128A = Bar128AB(BarTextInA, 0)
    End Function


    ' This function converts a string into a format compatible with Elfring
    ' Fonts Inc bar codes. This conversion is for UCC/EAN, subset A only.
    ' It adds the two start characters, scans and converts data, adds a checksum
    ' and a stop character. Note that lower case letters are interpreted as control
    ' characters in subset A!
    '---------------------------------------------------------
    Private Function Bar128Aucc(ByVal BarTextInA As String) As String
        ' Add FNC1 to beginning of string
        TempString = Chr(172) & BarTextInA
        Bar128Aucc = Bar128AB(TempString, 0)
    End Function


    ' This function converts a string into a format compatible with Elfring
    ' Fonts Inc bar codes. This conversion is for subset B only. It adds the
    ' start character, scans and converts data, adds a checksum and a stop
    ' character.
    '------------------------------------------------------
    Private Function Bar128B(ByVal BarTextInB As String) As String
        Bar128B = Bar128AB(BarTextInB, 1)
    End Function


    ' This function converts a string into a format compatible with Elfring
    ' Fonts Inc bar codes. This conversion is for UCC/EAN, subset B only.
    ' It adds the two start characters, scans and converts data, adds a checksum
    ' and a stop character.
    '---------------------------------------------------------
    Private Function Bar128Bucc(ByVal BarTextInB As String) As String
        ' Add FNC1 to beginning of string
        TempString = Chr(172) & BarTextInB
        Bar128Bucc = Bar128AB(TempString, 1)
    End Function


    '-----------------------------------------------------------------------------
    ' Convert input string to bar code 128 A or B format, Pass Subset 0 = A, 1 = B
    '-----------------------------------------------------------------------------
    Private Function Bar128AB(ByVal BarTextIn As String, ByVal Subset As Integer) As String

        ' Initialize input and output strings
        BarTextOut = ""
        BarTextIn = RTrim(LTrim(BarTextIn))

        ' Set up for the subset we are in
        If Subset = 0 Then
            Sum = 103
            StartChar = "{"
        Else
            Sum = 104
            StartChar = "|"
        End If

        ' Calculate the checksum, mod 103 and build output string
        For II As Integer = 1 To Len(BarTextIn)
            'Find the ASCII value of the current character
            ThisChar = (Asc(Mid(BarTextIn, II, 1)))
            'Calculate the bar code 128 value
            If ThisChar < 123 Then
                CharValue = ThisChar - 32
            Else
                CharValue = ThisChar - 70
            End If
            'add this value to sum for checksum work
            Sum = Sum + (CharValue * II)

            'Now work on output string, no spaces in TrueType fonts
            If Mid(BarTextIn, II, 1) = " " Then
                BarTextOut = BarTextOut & Chr(174)
            Else
                BarTextOut = BarTextOut & Mid(BarTextIn, II, 1)
            End If
        Next II

        ' Find the remainder when Sum is divided by 103
        CheckSumValue = (Sum Mod 103)
        ' Translate that value to an ASCII character
        If CheckSumValue > 90 Then
            CheckSum = Chr(CheckSumValue + 70)
        ElseIf CheckSumValue > 0 Then
            CheckSum = Chr(CheckSumValue + 32)
        Else
            CheckSum = Chr(174)
        End If

        'Build ouput string, trailing space is for Windows rasterization bug
        BarCodeOut = StartChar & BarTextOut & CheckSum & "~ "

        'Return the string
        Bar128AB = BarCodeOut
    End Function


    ' This function converts a string into a format compatible with Elfring
    ' Fonts Inc bar codes. This conversion is for subset C only. It adds the
    ' start character, throws away any non-numeric data, adds a leading zero if
    ' there aren't an even number of digits, scans and converts data into data
    ' pairs, adds a checksum and a stop character.
    '-----------------------------------------------------
    Public Function Bar128C(ByVal BarTextIn As String) As String
        Bar128C = Bar128SubsetC(BarTextIn, 0)
    End Function

    ' This function converts a string into a format compatible with Elfring
    ' Fonts Inc bar codes. This conversion is for UCC/EAN subset C only. It adds
    ' the two start characters, throws away any non-numeric data, adds a leading
    ' zero if there aren't an even number of digits, scans and converts data into
    ' data pairs, adds a checksum and a stop character.
    '--------------------------------------------------------
    Private Function Bar128Cucc(ByVal BarTextIn As String) As String
        Bar128Cucc = Bar128SubsetC(BarTextIn, 1)
    End Function

    '---------------------------------------------------------------------------
    ' Convert input string to bar code 128 C format, Pass UCC 0 = no, 1 = yes
    '---------------------------------------------------------------------------
    Private Function Bar128SubsetC(ByVal BarTextIn As String, ByVal UCC As Integer) As String
        Dim I As Integer

        ' Initialize input and output strings
        BarTextOut = ""
        BarTextIn = RTrim(LTrim(BarTextIn))

        ' Throw away non-numeric data
        TempString = ""
        For I = 1 To Len(BarTextIn)
            If IsNumeric(Mid(BarTextIn, I, 1)) Then
                TempString = TempString & Mid(BarTextIn, I, 1)
            End If
        Next I

        ' If not an even number of digits, add a leading 0
        If (Len(TempString) Mod 2) = 1 Then
            TempString = "0" & TempString
        End If

        ' If UCC = 0, then normal start, otherwise UCC/EAN start
        If UCC = 0 Then
            Sum = 105
            StartChar = "}"
            Weighting = 1
        Else
            Sum = 207
            StartChar = "}²"
            Weighting = 2
        End If

        ' Calculate the checksum, mod 103 and build output string
        For I = 1 To Len(TempString) Step 2
            'Break string into pairs of digits and get value
            CharValue = Mid(TempString, I, 2)
            'Multiply value times weighting and add to sum
            Sum = Sum + (CharValue * Weighting)
            Weighting = Weighting + 1

            'translate value to ASCII and save in BarTextOut
            If CharValue < 90 Then
                BarTextOut = BarTextOut & Chr(CharValue + 33)
            ElseIf CharValue < 171 Then
                BarTextOut = BarTextOut & Chr(CharValue + 71)
            Else
                BarTextOut = BarTextOut & Chr(CharValue + 76)
            End If
        Next I

        ' Find the remainder when Sum is divided by 103
        CheckSumValue = (Sum Mod 103)
        ' Translate that value to an ASCII character
        If CheckSumValue < 90 Then
            CheckSum = Chr(CheckSumValue + 33)
        ElseIf CheckSumValue < 100 Then
            CheckSum = Chr(CheckSumValue + 71)
        Else
            CheckSum = Chr(CheckSumValue + 76)
        End If

        'Build ouput string, trailing space for Windows rasterization bug
        BarCodeOut = StartChar & BarTextOut & CheckSum & "~ "

        'Return the string
        Bar128SubsetC = BarCodeOut
    End Function
End Class 
by

Visual basic (VB.net) Online Compiler

Write, Run & Share VB.net code online using OneCompiler's VB.net online compiler for free. It's one of the robust, feature-rich online compilers for VB.net language, running on the latest version 16. Getting started with the OneCompiler's VB.net compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as VB.net. OneCompiler also has reference programs, where you can look for the sample code to get started with.

Read input from STDIN in VB.net

OneCompiler's VB.net online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample VB.net program which takes name as input and prints hello message with your name.

Public Module Program
	Public Sub Main(args() As string)
	 Dim name as String = Console.ReadLine()    ' Reading input from STDIN
   Console.WriteLine("Hello " & name)           ' Writing output to STDOUT
	End Sub
End Module

About VB.net

Visual Basic is a event driven programming language by Microsoft, first released in the year 1991.

Key Features

  • Beginner's friendly language.
  • Simple and object oriented programming language.
  • User friendly language and easy to develop GUI based applications.

Syntax help

Variables

Variable is a name given to the storage area in order to identify them in our programs.

Simple syntax of Variable declaration is as follows

Dim variableName [ As [ New ] dataType ] [ = initializer ]

Variable initialization

variableName = value

Conditional Statements

1. If

If condition-expression Then 
    'code
End If

2. If-else

If(conditional-expression)Then
   'code if the conditional-expression is true 
Else
  'code if the conditional-expression is false 
End If

3. If-else-if ladder

If(conditional-expression)Then
   'code if the above conditional-expression is true 
Else If(conditional-expression) Then
        'code if the above conditional-expression is true 
    Else
        'code if the above conditional-expression is false 
End If

4. Nested-If

If(conditional-expression)Then
   'code if the above conditional-expression is true
   If(conditional-expression)Then
         'code if the above conditional-expression is true 
   End If
End If

5. Select Case

Select [ Case ] expression
   [ Case expressionlist
      'code ]
   [ Case Else
      'code ]
End Select

Loops

1. For..Next

For counter [ As datatype ] = begin To end [ Step step ]
   'code
   [ Continue For ]
   'code
   [ Exit For ]
   'code
Next [ counter ]

2. For..Each

For Each element [ As datatype ] In group
   'code
   [ Continue For ]
   'code
   [ Exit For ]
   'code
Next [ element ]

3. While

While conditional-expression
   'Code 
   [ Continue While ]
   'Code
   [ Exit While ]
   'Code
End While

4. Do-while

Do { While | Until } conditional-expression
   'Code
   [ Continue Do ]
   'Code
   [ Exit Do ]
   'Code
Loop
Do
   'Code
   [ Continue Do ]
   'Code
   [ Exit Do ]
   'Code
Loop { While | Until } conditional-expression

Procedures

Procedure is a sub-routine which contains set of statements. Usually Procedures are written when multiple calls are required to same set of statements which increases re-usuability and modularity.

Procedures are of two types.

1. Functions

Functions return a value when they are called.

[accessModifiers] Function functionName [(parameterList)] As returnType
   'code
End Function

2. Sub-Procedures

Sub-procedures are similar to functions but they don't return any value.

Sub ProcedureName (parameterList)
'Code
End Sub