if Sender if TEdit then if (TEdit(Sender).Text='') or (TEdit(Sender).Text[TEdit(Sender).SelStart]='') or (TEdit(Sender).SelLength= Length(TEdit(Sender).Text)) and (Key in [''a''..''z'']) then Key:=UpperCase(Key);
就不如这样的代码来得简洁易读:
if Sender is TEdit then with Sender as TEdit do if (Text='') or (Text[SelStart]='') or (SelLength=Length(Text)) and (Key in [''a''..''z''] then Key:=UpCase(Key);