FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

TEXT

Limit the number of characters in an Edit Field


I encountered this problem but solved it fairly easily. Use ON EDIT fn filterKeys to check the number of characters in the field each time a key is pressed:

LOCAL FN filterKeys
  key$ = TEKEY$
  LONG IF LEN(EDIT$(efID)) =< maxChars
    TEKEY$ = key$ 'Ok send the keystrokes through
  XELSE
    BEEP 'Too many chars in edit field!
  END IF
END FN

ON EDIT fn filterKeys

LakeR