Brandon Jake Sullano
Brandon Jake Sullano

Reputation: 335

How to determine if textbox inside userform1 was clicked? and get its value so I can do msgbox then display the text?

Hi I'm not sure if this is doable or not. I'm trying to get the value of an input box in my userform and display it in a MsgBox during the time that it was focused or clicked.

Is there a way to do this?

Say I have Textbox1 with a value of Apple and when I click that TextBox1 MsgBox will appear that will display the value of my TextBox1 which is Apple.

Note: I have a lot of TextBox so I'm not only referring to TextBox1.

Thanks for the help.

Upvotes: 0

Views: 1046

Answers (1)

Pᴇʜ
Pᴇʜ

Reputation: 57683

You can either use the TextBox1_Enter() event (when the text box is entered) or the TextBox1_MouseUp event (when the text box is clicked) to trigger a message box and you will have to do this for each Textbox.

But you can use procedure:

Option Explicit

Private Sub ShowMyMsgBog(Value As String)
    MsgBox Value
End Sub

'you need one event for each TextBox
Private Sub TextBox1_Enter()
    ShowMyMsgBog TextBox1
End Sub

Private Sub TextBox2_Enter()
    ShowMyMsgBog TextBox2
End Sub

Upvotes: 1

Related Questions