If MsgBox("Attenzione! Il nome inserito contiene pi∙ di 30 caratteri. Si desidera troncare il nome a lunghezza 30?", vbYesNo, "Contact Manager v1.0") = vbNo Then Exit Property
End If
PNome = Left$(TNome, 30)
ReturnError (0)
End Property
Private Sub ReturnError(ErrorCode As Integer)
If ErrorCode = 0 Then
PError = 0
PErrDescription = ""
Exit Sub
End If
If ErrorCode = 1 Then
PError = 1
PErrDescription = "Errore generico"
Exit Sub
End If
If ErrorCode = 2 Then
PError = 2
PErrDescription = "Errore relativo alla data di nascita"
Exit Sub
End If
End Sub
Public Property Get Cognome() As String
Cognome = PCognome
ReturnError (0)
End Property
Public Property Let Cognome(TCognome As String)
If Len(TCognome) > 30 Then
If MsgBox("Attenzione! Il cognome inserito contiene pi∙ di 30 caratteri. Si desidera troncarlo a lunghezza 30?", vbYesNo, "Contact Manager v1.0") = vbNo Then Exit Property
End If
PCognome = Left$(TCognome, 30)
ReturnError (0)
End Property
Public Property Get Indirizzo() As String
Indirizzo = PIndirizzo
ReturnError (0)
End Property
Public Property Let Indirizzo(TIndirizzo As String)
If Len(TIndirizzo) > 100 Then
If MsgBox("Attenzione! L'indirizzo inserito contiene pi∙ di 100 caratteri. Si desidera troncarlo a lunghezza 100?", vbYesNo, "Contact Manager v1.0") = vbNo Then Exit Property
End If
PIndirizzo = Left$(TIndirizzo, 100)
ReturnError (0)
End Property
Public Property Get Data() As Date
Data = PData
ReturnError (0)
End Property
Public Property Let Data(TData As Date)
If DateDiff("d", Now, TData) < 3650 Then
Rem MsgBox "La data inserita Φ troppo vicina a quella odierna. E' necessario cambiarla!", vbExclamation, "Contacts Manager v1.0"
ReturnError (2)
RaiseEvent OnError
Exit Property
End If
PData = TData
ReturnError (0)
End Property
Public Property Get Error() As Integer
Error = PError
End Property
Public Property Get ErrDescription() As String
ErrDescription = PErrDescription
End Property
Public Function Exist(Source As Database) As Boolean
SQLStatement = "SELECT * FROM CONTATTI WHERE NOME='" + PNome + "' AND COGNOME='" + PCognome + "'"