StealthRT
StealthRT

Reputation: 10542

VB6 sending keypress to a textbox

Hey all, i am looking for a way to send a keypress letter/number to a textbox. The reason why i need this is that this textbox is a AutoComplete box that, when the user types, it displays a list of suggestions like google does.

However, for it to work, the user has to click in the box and type something. I can send any number/letter to the box i want using this code:

 Private Sub Command_Click()
     AutoComplete1.Text = "g"
 End Sub

And it does put it into the textbox but it does not trigger the autocomplete list (the list has words like "good","great","pop","test"). Only when i click in the textbox and type "g" is the only time i get the "good","great" suggestions.

Is there a way to trigger this with the code i posted above?

Thanks!

David

Upvotes: 0

Views: 1999

Answers (3)

Claudio
Claudio

Reputation: 39

My guess would be to use Keyup event and fire the code that displays the list of suggestion if it isn't fired by the Keyup event itself

Upvotes: 0

SteveCav
SteveCav

Reputation: 6729

Wouldn't

AutoComplete1.SetFocus()
SendKeys("g")

do that?

Upvotes: 2

Raj More
Raj More

Reputation: 48016

How about putting the code in the Key_Press event of the textbox instead of click event of the command button?

Upvotes: 0

Related Questions