Buongiorno. Vorrei implementare una funzione sui miei textbox e vi spiego quale.
Digito la prima lettera sulla text ed automaticamente mi scrive il primo nome del DB che trova, poi scrivo la seconda lettera e mi propone il primo nome che inizia con quelle lettere e così via. La particolarità è che dovrebbe lasciarmi le lettere che scrivo io DESELEZIONATE mentre il resto del nome SELEZIONATO. Ho allegato un'immagine per spiegare meglio, spero si veda.
Io cmq ho buttato giù una mia procedura, funziona però la vedo lenta... c'è qualche tecnica più performante? Grazie
Private Sub TextBox2_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox2.KeyUp
Dim a As Integer
Dim strSQL As String
lunghezza = Len(TextBox2.Text)
strSQL = "SELECT motonave" _
& " , bandiera" _
& " , agenzia" _
& " , terminal" _
& " , ID" _
& " FROM tabellamotonavi " _
& " WHERE motonave LIKE '" & TextBox2.Text & "%'"
MioDbCmdMN.CommandText = strSQL
MioDbRst = MioDbCmdMN.Execute
esito = 0
If e.KeyCode < 32 Or e.KeyCode > 126 Then Exit Sub
With MioDbRst
If .EOF Then Exit Sub 'non trovato esce dalla sub
For a = 1 To Len(TextBox2.Text)
If Mid$(TextBox2.Text, a, 1) = Mid$(.Fields("motonave").Value, a, 1) Then
esito = 1
Else
esito = 0
Exit For
End If
Next a
If esito = 1 Then
TextBox2.Text = TextBox2.Text + Mid$(.Fields("motonave").Value, lunghezza + 1)
TextBox2.SelectionStart = lunghezza
TextBox2.SelectionLength = Len(TextBox2.Text)
End If
End With
End Sub