ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear Contents Of A Text Box In User Form (https://www.excelbanter.com/excel-programming/295907-clear-contents-text-box-user-form.html)

Graham[_5_]

Clear Contents Of A Text Box In User Form
 
Hi,

I have a text box in a user form for user to enter a
password. A command button is on the user form for the
user to click "OK" when they have entered the password.If
the incorrect password is entered my macro loops around
for the user to try again. However I cannot get my text
box to clear, so if multiple password attempts are
required, a very long text string is created thus making
it impossible to enter the correct password.

Grateful for help on ways around this.

Thanks
Graham

Bob Phillips[_6_]

Clear Contents Of A Text Box In User Form
 
Graham,

You don't need to clear it, just select everything so that the next typing
overwrites

With TextBox1
If .Text < "myPassword" Then
MsgBox "Invalis password"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End If
End With

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Graham" wrote in message
...
Hi,

I have a text box in a user form for user to enter a
password. A command button is on the user form for the
user to click "OK" when they have entered the password.If
the incorrect password is entered my macro loops around
for the user to try again. However I cannot get my text
box to clear, so if multiple password attempts are
required, a very long text string is created thus making
it impossible to enter the correct password.

Grateful for help on ways around this.

Thanks
Graham





All times are GMT +1. The time now is 11:30 PM.

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