Dichiarazioni (private / public dipende da te)

codice:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
    hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    lParam As Any) As Long

Const EM_CANUNDO = &HC6
Const EM_UNDO = &HC7
Const EM_EMPTYUNDOBUFFER = &HCD
Codice

codice:
 
' se vuoi sapere se si puo' fare l'undo
Dim bUndo as Boolean

bUndo = SendMessage(textbox.hWnd, EM_CANUNDO, 0, ByVal 0&)
'---------------------------------------

' esegue undo
SendMessage textbox.hWnd, EM_UNDO, 0, ByVal 0&

' ripulisce il buffer della textbox
SendMessage textbox.hWnd, EM_EMPTYUNDOBUFFER, 0, ByVal 0&

puoi crearti una funzione a cui passi l'oggetto textbox o fare un controllo sul controllo attivo verificando se sia textbox.