EDIT的输入限制值可以在Edit的ONKeyPress事件里写如下代码即可:)if not (Key in ['0'..'9',#8]) then Key := #0 else if (Length(Edit1.Text) > 0) and (Key <> #8) and (StrToInt(Edit1.Text + Key) > 255) then Key := #0;
偷个懒加个try.....except...就行了
不知道MaskEdit可以实现吗!??
if (StrToInt(Edit1.Text)>255) or (StrToInt(Edit2.Text)>255) or (StrToInt(Edit3.Text)>255) then begin showmessage('輸入的值不能超過255'); exit; end; Memo1.Color := RGB(StrToInt(Edit1.Text), StrToInt(Edit2.Text), StrToInt(Edit3.Text));
當然,需要事先對三個Edit裏的内容進行check,否則會出錯。
限制一下edit中输入的值
else
if (Length(Edit1.Text) > 0) and (Key <> #8) and (StrToInt(Edit1.Text + Key) > 255) then Key := #0;
begin
showmessage('輸入的值不能超過255');
exit;
end;
Memo1.Color := RGB(StrToInt(Edit1.Text), StrToInt(Edit2.Text), StrToInt(Edit3.Text));
// 當然,需要事先對三個Edit裏的内容進行check,否則會出錯。哈哈!不好意思,純屬筆誤,應該是Edit1,Edit2,Edit3