Help with adding controls

B

Badtaste2k

Hi, I just learned about adding controls to a userform through coding and it
seems very useful. However, i was wondering if it is possible to make the
controls added use _change functions?

For example, on my code i have a textbox added when a user clicks a button.
I name the textbox "Scan2"
I know i can access the data in the new textbox by using
userform1.controls("Scan2") However, i need to use a function that evaluates
each character entered into the box and wait's for a ctrl key (chr(10)) to
be pressed. When pressed, it runs a different function.

If i had hard coded the textbox, i would use

Private Sub Scan2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = 17 Or KeyCode = 13 Then
call searchdata()
KeyCode = 0
End If

End Sub

any help would be great.

oh, i tried doing private sub homer.controls("scan2")_keydown...etc.. but of
course that didn't work. It's never that easy :)

Dan Butler
(e-mail address removed)
 

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

Similar Threads


Top