prova in questo modo:
codice:
Function Incrementa_Indice(ByVal old_id As String) As String
Dim new_id As String, left_id As String, right_id As String
'controlla che l'ID sia corretto
If InStr(1, old_id, "/") <> 0 Then
'************************PARTE SINISTRA DELL'ID**********************
'recupera le cifre a sinistra di /
left_id = Left(old_id, InStr(1, old_id, "/") - 1)
'incrementa new_id
left_id = CInt(left_id + 1)
'aggiunge uno 0 se il numero è minore di 10
If left_id <= 9 Then
left_id = CStr("0" & left_id)
Else
left_id = CStr(left_id)
End If
'************************PARTE DESTRA DELL'ID*************************
'se l'anno è rappresentato sempre con due cifre
right_id = Right(old_id, 2)
'se l'anno non corrisponde con quello della data di sistema assegna a right_id le due cifre dell'anno corrente
If right_id <> Right(Year(Date), 2) Then
right_id = Right(Year(Date), 2)
End If
'Genera il nuovo id
new_id = left_id & "/" & right_id
Incrementa_Indice = new_id
Else
MsgBox "L'identificatore non è corretto", vbInformation, "Errore:"
Incrementa_Indice = old_id
End If
End Function
Private Sub Command1_Click()
Text1.Text = Incrementa_Indice(Text1.Text)
End Sub
così dovrebbe funzionare a dovere, naturalmente controlla che il campo ID del db si una stringa