Autor Beitrag
webmaker
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 205



BeitragVerfasst: So 19.10.03 19:06 
Hi Leute,
wie kann ich einen Integer in einen Olevariant konvertieren?

_________________
.::Wissen ist Macht, nichts wissen macht nichts::.
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: So 19.10.03 21:39 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var
  MyVar: Variant;
  MyInt: Integer;
begin
  MyInt := 10;
  MyVar := MyInt;
end;

_________________
Ist Zeit wirklich Geld?
webmaker Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 205



BeitragVerfasst: Mo 20.10.03 10:35 
Wenn ich das so mache und es direkt in die Funktion, in der ein OleVAriant gebraucht wird, einsetze meckert Delphi rum
:arrow: Falscher Typ

_________________
.::Wissen ist Macht, nichts wissen macht nichts::.
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Mo 20.10.03 16:25 
Hallo,

normalerweise sollte das Beispiel von AndyB funktionieren.

Du kannst aber noch folgendes probieren:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button1Click(Sender: TObject);
var x:Integer;
    o:OleVariant;
begin
  x:=125;
  VarCast(o, x, varInteger);
  Label1.Caption:=VarToStr(o);
end;

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
webmaker Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 205



BeitragVerfasst: Mo 20.10.03 20:13 
Supi Danke!

_________________
.::Wissen ist Macht, nichts wissen macht nichts::.