I'm working with visual basic. How do i create a function to read from a list of words while typing and replace any word with the possible completed word while writing . like a t9 text function . this is the code I am working with .
Public Class Keyboard2
Private Property dval As Integer
Private Sub GoToNext_Click(sender As Object, e As EventArgs) Handles GoToNext.Click
'when this button is pressed the next possible word will be genereated and will replace the previous word by calling the "GetWord" Sub
GetWord()
End Sub
Private Sub GetWord()
dval = dval + 1 ' this value is used to ensure that there can be no error in word replacement and it separates each change.
Dim lastWord As String = RichTextBox1.Text.Split(" ").Last ' get the last word entered in the text box
If dval = 1 AndAlso RichTextBox1.Text.EndsWith("top") AndAlso lastWord = "top" Then
'To change the last word to the next possible word
RichTextBox1.Text = String.Concat(RichTextBox1.Text.Remove(RichTextBox1.Text.Length - lastWord.Length), "topmost")
End If
If dval = 2 AndAlso RichTextBox1.Text.EndsWith("topmost") AndAlso lastWord = "topmost" Then
RichTextBox1.Text = String.Concat(RichTextBox1.Text.Remove(RichTextBox1.Text.Length - lastWord.Length), "topping")
End If
If dval = 3 AndAlso RichTextBox1.Text.EndsWith("topping") AndAlso lastWord = "topping" Then
RichTextBox1.Text = String.Concat(RichTextBox1.Text.Remove(RichTextBox1.Text.Length - lastWord.Length), "top")
dval = 0
End If
End Sub
End Class
this method may be useful to some persons and i hope you will like it but for me it is a very bad method to use because i would have to enter thousands of words manually .
would I do this with a database? and does anyone have any examples . Thanks you for your time .