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.

Tuesday, 1 March 2016

Assembly Program to count no. of character in a string

;Assembly program to count no. of character in a stringorg 100h 
;code section
mov cl, 0               ;clear counter
mov bx, offset string   ;load address of string

repeat:                
mov al, [bx]            ;load first byte of string
cmp al, '$'             ;check is it end of string
je endit                ;if yes then goto endit label
inc bx                  ;else increase bx by 1
inc cl                  ;count this byte as string character
jmp repeat              ;goto repeat label to check next byte

endit:
add cl, '0'             ;convert byte to ASCII code
mov offset len, cl      ;save in memory

mov cx, 0               ;clear counter

;print output message
mov ah, 09h            
mov dx, offset msg
int 21h
mov dx, offset len
int 21h

ret

;data section
len db '0','$' 
string db "abcdefgh",'$'  
msg db "Length is : ",'$'



Assembly language program to read an array of numbers and find the minimal and maximal elements


;Asm program to compare an array to find minimal and maximum number
;maximal no. is stored in ah and minimal in al at the end of program
org 100h
; add your code here
Lea bx, ar          ;load address of array
mov cx, 1           ;start counter
mov al, [bx]        ;load first no. in al
mov ah, [bx]        ;load first no. in ah too

repeat:
cmp cx, 6           ;check counter for end of array
je endit            ;if yes then goto endit label
inc cx              ;increase counter by 1
inc bx              ;increase pointer move to next no. in array
mov dl, [bx]        ;load next no. in dl

cmp al, dl          ;compare previous and next no. in al and dl
jl skip1            ;if al < dl then goto skip1 label
mov al, dl          ;else load value of dl into al
jmp repeat          ;continue to next no.

skip1:
cmp ah, dl          ;compare ah and dl
jg repeat           ;if ah > dl then continue to next no.
mov ah, dl          ;else load value of dl into ah
jmp repeat          ;continue to next no.

endit:
ret

ar db 15,4,25,64,9,12  ;array



Assembly Program to convert string from lower case to upper case

 
;Program to convert string from lower case to upper case      org 100h
; add your code here
mov bx, offset str      ;load address of fisrt byte of str

repeat:
mov al, [bx]            ;load first byte of address store in bx
cmp al, '$'             ;check is it $ i.e. end of string
je print                ;if yes then goto print label

sub al, 20h             ;otherwise convert it into upper case by subtracting 20h
mov [bx], al            ;move back to str
inc bx                  ;move to next byte of str
jmp repeat              ;goto repeat

;this code section print str
print:
mov ah, 09h
mov dx, offset str
int 21h
ret
;data section
str db 'abcdefghijklmnopqrstuvwxyz','$'

Assembly Program to convert a number to ASCII string


;Assembly program to convert a number to ASCII string
org 100h   
jmp start               ;to start of code
number dw 19348         ;number to display
string db 10 dup('$')   ;string to store number in string format

start:
mov ax, number          ;load number

printnum:
mov cx, 0               ;set counter to 0, this will count no. of digits in number   
mov bx, 10              ;set divider value 10
repeat:      
mov dx, 0               ;set remainder empty
div bx                  ;divide ax by bx
add dx, '0'             ;convert to byte to digit
push dx                 ;push digit on stack
inc cx                  ;count digit
cmp ax, 0               ;check remaining num is 0
jne repeat              ;if not then goto repeat label

mov bx, offset string   ;load address of first byte of string
loadstring:
pop dx                  ;load digit from stack
mov [bx], dl            ;move digit to string
inc bx                  ;move to next byte of string
dec cx                  ;decrease counter
cmp cx, 0               ;check counter is 0
jne loadstring          ;if not then goto label loadstring

;print string generated
printstring:           
mov ah, 09h            
mov dx, offset string   ;load address of first byte of string ended by $ sign

int 21h                 ;DOS interrupt

ret                     ;return control to O/S