Allora, se non vuoi che si anteponga lo zero, devi togliere la parte in grassetto.codice:Private Sub Text1_Change(Index As Integer) If stato="modifica" then If Len(Text1(Index)) = 2 Then 'attenzione, la proprietà TabIndex delle textBox relative alle estrazioni,devono essere sequenziali dalla prima all'ultima SendKeys "{TAB}", True End If end if End Sub Private Sub Text1_Validate(Index As Integer, Cancel As Boolean) 'attenzione, la proprietà Maxlength delle textBox relative alle estazione, deve essere impostata a 2 If stato="modifica" then If Len(Trim(Text1(Index).Text)) > 0 Then If Len(Text1(Index).Text) = 1 Then Text1(Index).Text = "0" & Text1(Index).Text End If If Val(Text1(Index).Text) < 0 Or Val(Text1(Index).Text) > 90 Then MsgBox "L'estrazione deve essere compresa tra 0 e 90" Text1(Index).Text = "" Cancel = True ElseIf CheckNumber(Index) Then MsgBox "Il numero [" & Text1(Index) & "] è già inserito!" Text1(Index).Text = "" Cancel = True End If End If end if End Sub
Se vuoi usare sempre le stesse TextBox sia per visualizzare che per inserire/modificare allora devi fare le modifiche in rosso.
In pratica quanto sei in visualizzazione imposti la variabile stato="visualizza" mentre quando sei in insirimento/modifica imposti stato="modifica"

Rispondi quotando