Jump to content
ferreira12

txtbox visivel sobre um dado parametro

Recommended Posts

ferreira12

ola, queria que que a txt2 só ficasse visivel quando eu escrevesse na txt1 'site' ou 'loja', caso contrario devolve uma msgbox.

estou a utilizar o codigo abaixo mas nao estou a conseguir colocar da maneira que pertendo.

Private Sub txt1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txt1.KeyPress

    txt2.Visible = False
    If e.KeyChar = vbCr Then

	    ' If txt2.Visible = True Then
	    txt1.Text = "site"
	    'End If
    End If
   End Sub

Share this post


Link to post
Share on other sites
nelsonr

Algo assim?

Private Sub txt1_KeyUp(sender As Object, e As KeyEventArgs) Handles txt1.KeyUp
   If e.KeyCode = Keys.Enter Then
       If txt1.Text.ToLower() = "site" Or txt1.Text.ToLower() = "loja" Then
           txt2.Visible = True
       Else
           MessageBox.Show("errado")
       End If
   End If
End Sub

(coloca de inicio a txt2 com o visible=false)

Fiz o exemplo no keyup, mas podes seguir a mesma estrutura no keypress

Edited by nelsonr

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.