PEGAR O PRESSIONAMENTO SOMENTE DA 1¬šÃ€ŠÃ‚ª TECLA

WEBIER 27/12/2004 18:50:19
#57206
tenho esse código...

Private Sub txtLucro_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF2 Then
Produtos_ValorEstimado.Show 1
Else
'txtLucro.Text = ""
txtLucro.FontBold = False
txtLucro.FontItalic = False
txtLucro.FontUnderline = False
txtLucro.Alignment = 1
txtLucro.ForeColor = &H80000008
End If
End Sub

se for pressionado F2 ele abre tal form, senão ele limpa o textbox e aceita eu digitar... só que quando eu digito a 1Âê tecla ele limpa o textbox...quando eu apero a 2Âê tecla ele limpa novamente apagando a 1Âê letra que digitei.... como faço para ele limpa só quando eu pressionar a 1Âê tecla....
USUARIO.EXCLUIDOS 27/12/2004 18:58:27
#57211
Resposta escolhida
WEBIER, utilize o Len

fica assim:

Private Sub txtLucro_KeyDown(KeyCode As Integer, Shift As Integer) 
If KeyCode = vbKeyF2 Then
Produtos_ValorEstimado.Show 1
Else
if len(txtLucro.text)<1 then
txtLucro.Text = ""
txtLucro.FontBold = False
txtLucro.FontItalic = False
txtLucro.FontUnderline = False
txtLucro.Alignment = 1
txtLucro.ForeColor = &H80000008
end if
End If
End Sub
Tópico encerrado , respostas não são mais permitidas