Auto Complete Textbox Entry

E

eva2002

Hi,

I am working on a textbox that only allows 2 inputs. "E" or "C" char

However I would like to append a few more letters from current
position after user enter the letters.

But I can't seems to work it out. Can someone help me?

Example of problem, <E will produce Each> <C will produce Char>

steps

1) user enter "E"
2) textbox will show Each
3) user enter "C" after the E. The textbox will show ECharach.
4) user enter C at the last position. Textbox will show ECharachEach.

I know I could use the Insert function. However I wasn't able to
obtain the <starting index> which is the current index of the cursor
(the horizontal flashing line)
 
A

Allen

Hi,

I am working on a textbox that only allows 2 inputs. "E" or "C" char

However I would like to append a few more letters from current
position after user enter the letters.

But I can't seems to work it out. Can someone help me?

Example of problem, <E will produce Each> <C will produce Char>

steps

1) user enter "E"
2) textbox will show Each
3) user enter "C" after the E. The textbox will show ECharach.
4) user enter C at the last position. Textbox will show ECharachEach.

I know I could use the Insert function. However I wasn't able to
obtain the <starting index> which is the current index of the cursor
(the horizontal flashing line)

If I understand your problem correctly then in the LostFocus event of the
textbox you could try the following:

Select Case TextBox.Text
Case "C"
TextBox.Text = "Char"

Case "E"
TextBox.Text = "Each"
End Select

If I have the wrong end of the stick then please tell me so :)

--
ats@jbex

When Johnny comes marching home again
He's coming by bus or underground
A woman's eye will shed a tear
To see his face so beaten in fear
An' it was just around the corner in the English Civil War

The Clash - English Civil War
 
E

eva2002

If I understand your problem correctly then in the LostFocus event of the
textbox you could try the following:

Select Case TextBox.Text
        Case "C"
                TextBox.Text = "Char"

        Case "E"
                TextBox.Text = "Each"
End Select

If I have the wrong end of the stick then please tell me so :)

--
ats@jbex

When Johnny comes marching home again
He's coming by bus or underground
A woman's eye will shed a tear
To see his face so beaten in fear
An' it was just around the corner in the English Civil War

The Clash - English Civil War

Thanks for the reply

Actually, you are right to a certain point. The problem with this is
that you will overwrite the whole textbox content which is not what I
wanted.

What I need is to append addition letters after the letter user input.
The letter user input might be in the middle of a text.

E.g. current textbox.text = "Contain".
User input letter "E" after "o".
Output textbox.text = "CoEachntain".
"Each" is append after the letter "o". The remaining text of the
original string appears after "h"

User can enter "E" at any where in the text.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top