Object TextBox

J

Joao

Hello, what I am trying to doing is this:
2 TextBoxes (One for User, other for PW)
One button to accept the user/pw

I want the button disabled everytime user textbox or pw textbox is filled
with something less than 3 chars - My problem is that I don't like redundency
and I am trying to pass an objects, in this case user textbox/pw textbox,
trhu a function:

Private Sub txtUser_Change()
DesligarBotoes (txtUser)
End Sub

Private Sub txtUser_Change()
DesligarBotoes (txtPW)
End Sub

Function DesligarBotoes(objTextBoxID As TextBox)

Taman = Len(objTextBoxID.Text)

If objTextBoxID.Text = "" Or Taman <= 4 Then
btnValidar.Enabled = False
Else
btnValidar.Enabled = True
End If
End Function
 
K

Klatuu

Rewrite the function like this:

Function DesligarBotoes(objTextBoxID As TextBox)
btnValidar.Enabled = Len(objTextBoxID) > 3
End Function
 

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

Top