Clear Contents Of A Text Box In User Form

  • Thread starter Thread starter Graham
  • Start date Start date
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
 
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)
 

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

Back
Top