ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   event which occurs when a TextBox receives focus (https://www.excelbanter.com/excel-programming/278849-event-occurs-when-textbox-receives-focus.html)

Mikhail

event which occurs when a TextBox receives focus
 
When my text box receives focus, what event occurs?
I need this to be able to undo user's changes.

Dim OldValue as String
'when TextBox receives focus
OldValue = TextBox1.Text
'when user decides to discard changes
TextBox1.Text = OldValue

Thanks in advance,
Mike510



Tom Ogilvy

event which occurs when a TextBox receives focus
 
Where it the textbox. What type of control is it (Control toolbox Toolbar
or Drawing Toolbar)?

If on a worksheet and ActiveX/Control Toolbox Toolbar, then use the GotFocus
event.

--
Regards,
Tom Ogilvy



"Mikhail" wrote in message
...
When my text box receives focus, what event occurs?
I need this to be able to undo user's changes.

Dim OldValue as String
'when TextBox receives focus
OldValue = TextBox1.Text
'when user decides to discard changes
TextBox1.Text = OldValue

Thanks in advance,
Mike510





Dag Johansen[_5_]

event which occurs when a TextBox receives focus
 
Hi,

you could use the events of individual controls to achieve
this, but don't you find it a little unnatural? It seems
you are displaying a form to let the user edit something,
and the user should be able to choose to cancel. If I were
you I'd encapsulate the work into a single function
instead of bothering with individual control's events.

Using custom types this becomes very clean and simple. As
an example, let's assume we are editing a person in a
simple address book. Then the following should give you an
idea.

Type TPersonSettings

-----Original Message-----
When my text box receives focus, what event occurs?
I need this to be able to undo user's changes.

Dim OldValue as String
'when TextBox receives focus
OldValue = TextBox1.Text
'when user decides to discard changes
TextBox1.Text = OldValue

Thanks in advance,
Mike510


.



All times are GMT +1. The time now is 07:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com