VB6 How to detect sended key will be written in a textbox -


how detect sended key write in textbox? example: send "w" program active how can detect "w" written?

it depends on how send "w" program.... if mean if type, can use _keydown, _keyup or _keypress events of textbox..

private sub textbox_keypress(keyascii integer)   if keyascii = asc("w") call msgbox("yes 'w' pressed") end sub  private sub textbox_keydown(keycode integer, shift integer)   if keycode = vbkeyw , ((shift , vbshiftmask) = vbshiftmask) call msgbox("yes 'w' pressed") end sub 

or need track changes using _change event, ofcourse lot more work you'll need store previous text , compare current text, , see if 'w' has been added. have take account people might paste more 1 letter.

private sub textbox_change()   if instr(textbox.text, "w")>0     if instr(textbox.tag, "w") = 0       call msgbox("yep 'w' added")     else      'run down text along tag , see if 'w' present @ same location     end if   end if   textbox.tag = textbox.text end sub 

Comments