AppForge: Visual Basic for the Palm OS
by Clayton E. Crooks II

Listing One
Private NewRecord As Boolean
Private Sub btnBack_Click()
    PDBMovePrev dbSigsTime
    DisplayInfo
End Sub

Private Sub btnExit_Click()
    Unload Me
End Sub

Private Sub btnNext_Click()
    PDBMoveNext dbSigsTime
    DisplayInfo
End Sub

Private Sub btnDelete_Click()
    If NewRecord Then
        ClearDisplay
        NewRecord = False
        DisplayInfo
    ElseIf PDBNumRecords(dbSigsTime) > 0 Then
        PDBDeleteRecord dbSigsTime
        DisplayInfo
    Else
        MsgBox "No records to delete"
    End If
End Sub

Private Sub btnNew_Click()
    NewRecord = True
    lblRecordDisplay.Caption = "New"
    txtDate.Text = ""
    txtTime.Text = ""
    ClearDisplay
End Sub

Private Sub btnSave_Click()
    Dim MyRecord As tSigsTimeRecord
    
    If NewRecord Then
        PDBCreateRecordBySchema dbSigsTime
    End If
    
    MyRecord.Name = txtName.Text
    MyRecord.Signature = sigName.SignatureData
    MyRecord.Date = txtDate.Text
    MyRecord.Time = txtTime.Text
    
    PDBEditRecord dbSigsTime
    WriteSigsTimeRecord MyRecord
    PDBUpdateRecord dbSigsTime
    
    DisplayInfo
End Sub

Private Sub Form_Load()
    If OpenSigsTimeDatabase = False Then
        #If APPFORGE Then
        dbSigsTime = PDBCreateDatabase("SigsTime", 
                                       SigsTime_TypeID, SigsTime_CreatorID)
        #Else
        dbSigsTime = PDBCreateDatabase(App.Path & "\SigsTime", 
                                       SigsTime_TypeID, SigsTime_CreatorID)
        #End If
        
        PDBCreateTable dbSigsTime, "Signatures", 
                                      "Name String, Signature String"
    End If
        
    PDBMoveFirst dbSigsTime
    DisplayInfo
End Sub

Private Sub DisplayInfo()
    Dim MyRecord As tSigsTimeRecord
    
    If PDBNumRecords(dbSigsTime) > 0 Then
        NewRecord = False
        ReadSigsTimeRecord MyRecord
        
        txtName.Text = MyRecord.Name
        sigName.SignatureData = MyRecord.Signature
        txtDate.Text = MyRecord.Date
        txtTime.Text = MyRecord.Time
    
        lblRecordDisplay.Caption = CStr(PDBCurrentIndex(dbSigsTime) + 1) + 
                                    " of " + CStr(PDBNumRecords(dbSigsTime))
    Else
        NewRecord = True
        lblRecordDisplay.Caption = "0 of 0"
        ClearDisplay
    End If
End Sub

Private Sub ClearDisplay()
  sigName.Clear
  txtName.Text = ""
End Sub






2

