Make your own free website on Tripod.com
Undo The Last User Action In Text Box

The user can undo his last editing in a text box via the Undo item on the text box pop up menu. You can do the same through code.

Preparations

Add 1 Text Box and 1 Command Button to your form.
Press the button to undo the last user action.

Module Code

Declare Function SendMessageBynum& Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    ByVal lparam As Long)
Public Const EM_UNDO = &HC7&

Form Code

Private Sub TextUndo(T As TextBox)
    SendMessageBynum T.hwnd, EM_UNDO, 0, 0
End Sub

Private Sub Command1_Click()
'replace the "Text1" below with the name of the Text Box you want to
'apply the Undo on it.
   
Call TextUndo(Text1)
End Sub

Go Back