Clear Contents Of A Text Box In User Form

G

Graham

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
 
B

Bob Phillips

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)
 
Top