Use Api also can do it. But easy way is like this.
If KeyCode = 37 Then
uu = Text1.SelStart
ii = Text1.SelText
If uu > 0 Then
Text1 = Left$(Text1, uu) & "4" & Right(Text1, Len(Text1) - Len(ii) - uu)
Text1.SelStart = uu + 2
End If
End If
-------------试试键盘Hook吧-----------------------
-------------以下在Bas中----------------------
public declare function callnexthookex lib "user32" (byval hhook as long, byval ncode as long, byval wparam as long, byval lparam as long) as long
public declare function unhookwindowshookex lib "user32" (byval hhook as long) as long
public declare function setwindowshookex lib "user32" alias "setwindowshookexa" (byval idhook as long, byval lpfn as long, byval hmod as long, byval dwthreadid as long) as long
public declare function postmessage lib "user32" alias "postmessagea" (byval hwnd as long, byval wmsg as long, byval wparam as long, byval lparam as long) as long
public const wh_keyboard = 2
public const kbh_mask = &h20000000
public const wm_lbuttondown = &h201
public const wm_lbuttonup = &h202
global hhook as long
'keyboardproc 在 vb 应用动作前发生
public function keyboardproc(byval ncode as long, byval wparam as long, byval lparam as long) as long
if ncode >= 0 then
'处理你希望过滤的键
if wparam = asc("c") and (lparam and kbh_mask) <> 0 then
if (lparam and &hc0000000) = 0 then
keyboardproc = 1
end if
end if
end if
keyboardproc = callnexthookex(hhook, ncode, wparam, lparam)
end function