Notifications
Clear all

Senha em TextBox

6 Posts
3 Usuários
0 Reactions
1,300 Visualizações
(@miguel-70)
Posts: 0
New Member
Topic starter
 

Ola, novamente!
Como faço para fazer funcionar este código, quero que funciona assim;
TextBox verifica se a senha é a mesma que esta na Plan1.Range ("A1")

Private Sub CommandButton1_Click()
Dim Linha As Long
Dim Linhas As Long
If TextBox1 = Plan1.Range("A1").Value Then
MsgBox "Senha Correta"
Else
MsgBox "Senha digitada inválida, verificar."
Exit Sub
End If
End Sub

Obrigado.

 
Postado : 26/02/2015 1:00 pm
(@gtsalikis)
Posts: 2373
Noble Member
 

E qual o problema? deveria funcionar.

No máximo, alterando essa linha:
If TextBox1 = Plan1.Range("A1").Value Then

Para:
If TextBox1.Value = Sheets("Plan1").Range("A1").Value Then

Ou para :
If Me.TextBox1.Value = Sheets("Plan1").Range("A1").Value Then

Mas, depende de onde vc está colocando o código, pode ter outras coisas. Sem o modelo da planilha...

 
Postado : 26/02/2015 1:04 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Boa tarde!!

Veja:
http://www.google.com.br/cse?cx=partner ... gsc.page=1

Att

 
Postado : 26/02/2015 1:14 pm
(@miguel-70)
Posts: 0
New Member
Topic starter
 

Não deu certo, se puder me ajudar fico agradecido, segue modelo em anexo.

 
Postado : 26/02/2015 3:13 pm
(@gtsalikis)
Posts: 2373
Noble Member
 

Está dando um conflito pelo fato de ter números.

Forcei para que tudo seja interpretado como string:

Troque esta linha:
If Me.TextBox1.Value = Sheets("Plan1").Range("A1").Value Then

Por esta:
If CStr(Me.TextBox1.Value) = CStr(Sheets("Plan1").Range("A1").Value) Then

 
Postado : 26/02/2015 3:24 pm
(@miguel-70)
Posts: 0
New Member
Topic starter
 

Resolvido, obrigado Gilmar, postei o codigo para futuras dúvidas dos leitores

Private Sub CommandButton1_Click()
Dim Linha As Long
Dim Linhas As Long
If CStr(Me.TextBox1.Value) = CStr(Sheets("Plan1").Range("A1").Value) Then
MsgBox "Senha Correta"
TextBox1 = Clean
CommandButton2.Visible = True
Else
MsgBox "Senha digitada inválida, verificar."
Exit Sub
End If
End Sub
Private Sub CommandButton2_Click()
Plan1.Range("A1") = TextBox1
MsgBox "Nova Senha Registrada com Exito"
End Sub
Private Sub UserForm_Activate()
CommandButton2.Visible = False
End Sub

 
Postado : 26/02/2015 3:33 pm