Object TextBox

  • Thread starter Thread starter Joao
  • Start date Start date
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
 
Rewrite the function like this:

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