Z zyin Unregistered / Unconfirmed GUEST, unregistred user! 2002-01-21 #1 请问,如何将OleVariant类型的变量转换为Integer,string等其它类型.
Y yzhshi Unregistered / Unconfirmed GUEST, unregistred user! 2002-01-21 #2 强制类型转换不可以吗? aaa: OleVariant; Integer(aaa)
D drawpharos Unregistered / Unconfirmed GUEST, unregistred user! 2002-01-21 #3 aaa: OleVariant; bbb:Integer; bbb:=aaa as Integer;
Y yzhshi Unregistered / Unconfirmed GUEST, unregistred user! 2002-01-21 #4 可以的。 procedure TForm1.Button1Click(Sender: TObject); var aaa: OleVariant; begin aaa := 123; ShowMessage(IntToStr(Integer(aaa))); ShowMessage(String(aaa)); end;
可以的。 procedure TForm1.Button1Click(Sender: TObject); var aaa: OleVariant; begin aaa := 123; ShowMessage(IntToStr(Integer(aaa))); ShowMessage(String(aaa)); end;
H hnlygtjj Unregistered / Unconfirmed GUEST, unregistred user! 2002-01-21 #5 OleVariant是一个可变类型,它得到一个什么类型的值就是一个什么类型的值, 最好在给OleVariant赋值前就将类型转换好,然后就只管用了。:)
Z zyin Unregistered / Unconfirmed GUEST, unregistred user! 2002-01-22 #6 to drawpharos: 你提出的方法在编译时提示: Operator not applicable to this operand type. 谢谢了!
D drawpharos Unregistered / Unconfirmed GUEST, unregistred user! 2002-01-22 #7 呵呵,我也遇到过,但我忘了是怎么解决的了,反正很简单。现在一时想不起来。