Pergunta

I want to make this textbox: if I type "clean" and press enter, I want it to take action like below. Is there any ways to achieve it? Here's what I tried.

Private Sub TextBox1_Change()

If TextBox1.Text = "clean" + KeyCode(13) Then
Shell "cmd /c cleanmgr.exe", vbHide
End If
End Sub

Thanks.

Foi útil?

Solução

This is possibly what you are looking for:

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)

    If KeyCode = 13 Then
        If TextBox1.Text = "clean" Then

            MsgBox "ok" 'for test
            'do your stuff here!!

        End If
    End If

End Sub
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top