Below is my code:
var
i : integer;
...
...
if not VarIsNull(TcxLookupComboBox(Sender).EditValue) then
begin
i := Integer(TcxLookupComboBox(Sender).EditValue);
end;
I can use VarToStr
to convert variant into string but there is no VarToInt
in Delphi for this. So, I have converted it like this Integer(TcxLookupComboBox(Sender).EditValue)
. Is this the right approach?
i := TcxLookupComboBox(Sender).EditValue
. Compiler will do the conversion for you. – AbnegateEditValue
is a variant? (if not, it does not make sence to use variants to convert to integer). – PorushEditValue
contains'abc'
you're not going to be able to convert it to an integer. However, if it contains123
then simple assignment as indicated in TLama's comment is all that's needed. – Shamblin