Question

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.

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top