14/10/2025 - Mailman ha scritto:
@Alex la function non andrebbe richiamata con :
Private Sub Form_Current()
Call CheckAttachments
End Sub
??
Non è indispensabile usare CALL... prova come ho scritto....
Poi, se ho capito bene cio' che chiede Azucarea, vorrebbe scritto ad esempio: Istanza, Allegato A, Allegato B, Allegato C e Allegato D (se tutte le check sono spuntate), con la "e" solo sull'ultima check,
oppure: Istanza, Allegato B e Allegato D
oppure: Istanza, Allegato C
La tua function invece scrive: Allegato A e Allegato B e Allegato C e Allegato D (comunque con le "e" dopo ogni allegato)...
Secondo me andrebbero create le concatenazioni di stringhe in funzione delle varie combinazioni con una select Case...
Sbaglio?
Non avevo interpretato ma se è corretta la tua interpretazione... preferirei questa cosa decisamente meno contorta... e mi sono accorto che nel codice precedente ho introdotto molti errori...
Public Function CheckAttachments(b1 As Boolean, b2 As Boolean, b3 As Boolean, b4 As Boolean)
Dim strLabel As String
Dim varLabels As Variant
Dim intCount As Integer
If b1 Then strLabel = strLabel & "Allegato A,"
If b2 Then strLabel = strLabel & "Allegato B,"
If b3 Then strLabel = strLabel & "Allegato C,"
If b4 Then strLabel = strLabel & "Allegato D,"
If Len(strLabel) > 0 Then
strLabel = Mid$(strLabel, 1, Len(strLabel) - 1)
varLabels = Split(strLabel, ",")
strLabel = vbNullString
For intCount = 0 To UBound(varLabels) - 1
If intCount < UBound(varLabels) - 1 Then
strLabel = strLabel & varLabels(intCount) & ", "
Else
strLabel = strLabel & varLabels(intCount) & " e " & varLabels(intCount + 1)
End If
Next
Debug.Print strLabel
End If
End Function