Attribute VB_Name = "EVSB32"
Option Explicit

' Declare EVCHK32.DLL & EVMOV32.DLL functions
Declare Function EVCHK32 Lib "EVCHK32.DLL" (lpUserSB As SecureBlock) As Integer
Declare Function EVMOV32 Lib "EVMOV32.DLL" (lpUserSB As SecureBlock) As Integer


Function FormatError$(userSB As SecureBlock)
    Dim t As String

    ' format the SB error code into the Az-Tech display format
    ' i.e. 7XXX-XXXX-XXXX
    t$ = Left$("0000", 4 - Len(Hex$(userSB.STAT1))) + Hex$(userSB.STAT1)
    t$ = t$ + "-" + Left$("0000", 4 - Len(Hex$(userSB.STAT2))) + Hex$(userSB.STAT2)
    t$ = t$ + "-" + Left$("0000", 4 - Len(Hex$(userSB.STAT3))) + Hex$(userSB.STAT3)

    FormatError$ = t$
End Function

Sub ClearSB(lpSB As SecureBlock)
    ' clear the given SecureBlock structure to a known state
    lpSB.ID = "AZSB"
    lpSB.AUTH = 0
    lpSB.PTYPE = Chr$(0)
    lpSB.PROD = String$(9, 0)
    lpSB.SNP = 0
    lpSB.HNUC = 0
    lpSB.AVERS = 0
    lpSB.ECL = 0
    lpSB.DFT = 0
    lpSB.EDL = 0
    lpSB.ETL = 0
    lpSB.ED = String$(11, 0)
    lpSB.RSRVD0 = Chr$(0)
    lpSB.NUC = 0
    lpSB.NUL = 0
    lpSB.ICR = 0
    lpSB.ACCFLG = String$(8, 0)
    lpSB.USRDAT = String$(8, 0)
    lpSB.RTYPE = Chr$(0)
    lpSB.RNAME = String$(41, 0)
    lpSB.RSRVD1 = String$(10, 0)
    lpSB.RCOMP = String$(41, 0)
    lpSB.RSRVD2 = String$(10, 0)
    lpSB.RID = String$(41, 0)
    lpSB.RSRVD3 = String$(10, 0)
    lpSB.RDATE = String$(11, 0)
    lpSB.CDATE = String$(11, 0)
    lpSB.RSRVD4 = String$(14, 0)
    lpSB.STARTUP = String$(256, 0)
    lpSB.FUNC = 0
    lpSB.STAT1 = 0
    lpSB.STAT2 = 0
    lpSB.STAT3 = 0
    lpSB.SOURCE = String$(63, 0)
    lpSB.TARGET = String$(63, 0)
    lpSB.RSRVD2 = String$(2, 0)
    lpSB.PIN = 0
    lpSB.RUC = 0
    lpSB.RSRVD6 = String$(6, 0)
    lpSB.UNINST = 0
    lpSB.RSRVD7 = String$(5, 0)
    lpSB.VERREG = 0
    lpSB.CODE = String$(30, 0)
    lpSB.RSRVD8 = String$(64, 0)
    lpSB.RANDNUM = 0;
    lpSB.RSRVD9 = String$(6, 0)
End Sub






