''''22222222222222222222222Sub RunTest()
    PrintLB ("Btrieve Sample Test Started")
    PrintLB ("")Rem Local variables needed for conversion from byte to long.
Dim loc_RecTot  As Long
Dim h_field1    As String
Dim h_field2    As String
Dim h_field3    As String
Dim h_field4    As String
Dim h_total     As StringRem **************************FileName$ = "XFACE.BTR"PosBlk$ = Space$(128)
KeyBuffer$ = Space$(KEY_BUF_LEN)Rem
Rem ***************** Btrieve Create *********************
RemRem ************* SET UP FILE SPECS
FileBuf.RecLen = 34
FileBuf.PageSize = 1024
FileBuf.IndxCnt = 2
FileBuf.FileFlags = 0Rem ************* SET UP KEY SPECS
FileBuf.KeyBuf0.KeyPos = 1
FileBuf.KeyBuf0.KeyLen = 8
FileBuf.KeyBuf0.KeyFlags = EXTTYPE + MODIFIABLE
FileBuf.KeyBuf0.KeyType = Chr$(BFLOAT)FileBuf.KeyBuf1.KeyPos = 9
FileBuf.KeyBuf1.KeyLen = 26
FileBuf.KeyBuf1.KeyFlags = EXTTYPE + MODIFIABLE + DUP
FileBuf.KeyBuf1.KeyType = Chr$(BSTRING)BufLen = Len(FileBuf)
KeyBufLen = Len(FileName$)
KeyBuffer$ = FileName$
Status = BTRCALL(BCREATE, PosBlk$, FileBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, 0)If Status <> 0 Then
    Msg$ = "Error Creating File. Status = " + Str$(Status)
    PrintLB (Msg$)
Else
    Msg$ = "File XFACE.BTR Created Successfully!"
    PrintLB (Msg$)
End If'Open File
KeyBufLen = KEY_BUF_LEN
KeyBuffer$ = FileName$
BufLen = Len(DataBuf)
KeyNum = 0Status = BTRCALL(BOPEN, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, KeyNum)If Status <> 0 Then
    Msg$ = "Error Opening file! " + Str$(Status)
    PrintLB (Msg$)
    GoTo Fini
Else
    Msg$ = "File Opened Successfully!"
    PrintLB (Msg$)
End If'Insert First Record
yr = 1992
mo = 1
dy = 1
DataBuf.Number = DateSerial(yr, mo, dy)
BufLen = Len(DataBuf)
KeyBuffer$ = Space$(KEY_BUF_LEN)
KeyBufLen = KEY_BUF_LEN
DataBuf.Dummy = "first record"Status = BTRCALL(BINSERT, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, 0)If Status <> 0 Then
    Msg$ = "Error on Insert. " + Str$(Status)
    PrintLB (Msg$)
Else
    Msg$ = "Insert Record #1 Successful!"
    PrintLB (Msg$)
End If'Insert Second Record
yr = 1993
mo = 1
dy = 1
DataBuf.Number = DateSerial(yr, mo, dy)
BufLen = Len(DataBuf)
KeyBuffer$ = Space$(KEY_BUF_LEN)
KeyBufLen = KEY_BUF_LEN
DataBuf.Dummy = "second record"Status = BTRCALL(BINSERT, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, 0)If Status <> 0 Then
    Msg$ = "Error on Insert. " + Str$(Status)
    PrintLB (Msg$)
Else
    Msg$ = "Insert Record #2 Successful!"
    PrintLB (Msg$)
End If'Insert Third Record
yr = 1994
mo = 1
dy = 1
DataBuf.Number = DateSerial(yr, mo, dy)
BufLen = Len(DataBuf)
KeyBuffer$ = Space$(KEY_BUF_LEN)
KeyBufLen = KEY_BUF_LEN
DataBuf.Dummy = "third record"Status = BTRCALL(BINSERT, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, 0)If Status <> 0 Then
    Msg$ = "Error on Insert. " + Str$(Status)
    PrintLB (Msg$)
Else
    Msg$ = "Insert Record #3 Successful!"
    PrintLB (Msg$)
End If'Get First Record
BufLen = Len(DataBuf)
KeyBuffer$ = Space$(255)
KeyBufLen = KEY_BUF_LENStatus = BTRCALL(BGETFIRST, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, 0)If Status <> 0 Then
    Msg$ = "Error on BGETFIRST. " + Str$(Status)
    PrintLB (Msg$)
Else
    Msg$ = "BGETFIRST okay for : " + Str$(Year(DataBuf.Number)) + DataBuf.Dummy
    PrintLB (Msg$)
End If'Get Next Record
BufLen = Len(DataBuf)
KeyBuffer$ = Space$(KEY_BUF_LEN)
KeyBufLen = KEY_BUF_LENStatus = BTRCALL(BGETNEXT, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, 0)If Status <> 0 Then
    Msg$ = "Error on BGETNEXT. " + Str$(Status)
    PrintLB (Msg$)
Else
    Msg$ = "BGETNEXT okay for: " + Str$(Year(DataBuf.Number)) + DataBuf.Dummy
    PrintLB (Msg$)
End If'Get Next Record
BufLen = Len(DataBuf)
KeyBuffer$ = Space$(KEY_BUF_LEN)
KeyBufLen = KEY_BUF_LENStatus = BTRCALL(BGETNEXT, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, 0)If Status <> 0 Then
    Msg$ = "Error on BGETNEXT. " + Str$(Status)
    PrintLB (Msg$)
Else
    Msg$ = "BGETNEXT okay for: " + Str$(Year(DataBuf.Number)) + DataBuf.Dummy
    PrintLB (Msg$)
End If'Get Equal
BufLen = Len(DataBuf)
KBuf# = 33604
KeyBufLen = 8Status = BTRCALL(BGETEQUAL, PosBlk$, DataBuf, BufLen, KBuf#, KeyBufLen, 0)If Status <> 0 Then
    Msg$ = "Error on Get Equal. Status = " + Str$(Status)
    PrintLB (Msg$)
Else
    PrintLB ("BGETEQUAL okay on following key: " + Str$(DataBuf.Number))
End If'Stat Call
DBLen = Len(StatFileBuffer)
KeyBuffer$ = Space$(KEY_BUF_LEN)
KeyBufLen = KEY_BUF_LENStatus = BTRCALL(BSTAT, PosBlk$, StatFileBuffer, DBLen, ByVal KeyBuffer$, KeyBufLen, 0)If Status <> 0 Then
  Msg$ = "Error in Stat Call. Status = " + Str$(Status)
  PrintLB (Msg$)
  GoTo Fini
Else
Rem **********************************
Rem Code to work around problems with Visual Basic's "Double Word" alignment
Rem   This code converts the byte data to hexadecimal, concatenates each byte, and
Rem   converts it to decimal for display.
     h_field1 = Hex(StatFileBuffer.RecTot.fld_Field1)
     h_field2 = Hex(StatFileBuffer.RecTot.fld_Field2)
     h_field3 = Hex(StatFileBuffer.RecTot.fld_Field3)
     h_field4 = Hex(StatFileBuffer.RecTot.fld_Field4)
     h_total = "&H" & h_field4 & h_field3 & h_field2 & h_field1
     loc_RecTot = Val(h_total)
Rem **********************************
   Msg$ = "Number of Records = " & loc_RecTot
   PrintLB (Msg$)
End IfFini:
Status = BTRCALL(BRESET, PosBlk$, PatientVar, BufLen, KeyBuffer$, KeyBufLen, KeyNum)If Status Then
    Msg$ = "Error on B-Reset!" + Str$(Status)
    PrintLB (Msg$)
Else
   Msg$ = "BRESET okay."
   PrintLB (Msg$)
End IfStatus = BTRCALL(BSTOP, PosBlk$, PatientVar, BufLen, KeyBuffer$, KeyBufLen, KeyNum)If Status Then
   Msg$ = "Error on B-Stop!" + Str$(Status)
    PrintLB (Msg$)
Else
   Msg$ = "BSTOP okay."
   PrintLB (Msg$)
End If
PrintLB ("")
PrintLB ("Btrieve Sample Test Completed")End Sub