Wednesday 13 September 2017

Visual Basic 6 Function to generate Check Digit for GST No. (GSTIN) India


Public Function CheckSum(gstin As String) As String
    Dim symbList(0 To 35) As String * 1
    Dim gstinList(0 To 13) As String * 1
    Dim symbs As String
    Dim gstin14 As String
    Dim checkDigit As String
    Dim newCheckDigit As String
 
    Dim i As Integer, j As Integer
 
    checkDigit = Right(UCase(gstin), 1)
    gstin14 = Left(UCase(gstin), 14)
    For i = 0 To 13
        gstinList(i) = Mid(gstin14, i + 1, 1)
    Next
 
    symbs = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    For i = 0 To Len(symbs) - 1
        symbList(i) = Mid(symbs, i + 1, 1)
    Next
 
 
    Dim factor As Integer
    Dim sum As Integer
    Dim checkCodePoint As Integer
    Dim mode As Integer
 
    factor = 2: sum = 0: mode = Len(symbs)
 
    For i = UBound(gstinList) To 0 Step -1
        Dim codePoint As Integer, digit As Integer
        codePoint = -1
        For j = 0 To UBound(symbList)
            If symbList(j) = gstinList(i) Then
                codePoint = j
            End If
        Next
        digit = factor * codePoint
        factor = IIf(factor = 2, 1, 2)
        digit = (digit \ mode) + (digit Mod mode)
        sum = sum + digit
    Next

    checkCodePoint = (mode - (sum Mod mode)) Mod mode
    CheckSum = symbList(checkCodePoint)

End Function

Wednesday 6 September 2017

Using New for Object Creation with Dim v/s Set Command (Visual Basic 6)


    To Understand it, see the example given below

    For i = 1 To 10
        Dim c As New Collection            'executed only once in loop
        c.Add i
    Next
    MsgBox c.Count           'display 10

    For i = 1 To 10
        Dim d As Collection
        Set d = New Collection               'executed every time it encountered in loop
        d.Add i
    Next
    MsgBox d.Count             'display 1

    The output of first msgbox is 10 and output of second msgbox is 1. This is due to 'dim' command is executed only once even within a loop, while 'set' command is executed each time it encountered in loop.

Tuesday 15 August 2017

Punjabi Font like Anmollipi/Asees Viewer App for Android System

Just copy content from word file and paste in app to view it in Punjabi font like AnmolLipi/Asees.


Click here to download App...

Disclaimer: Assumes no responsibility for errors or omissions in the contents on the Service.