Kaf_Dağı | 18 Mart 2015 14:15 | Döviz Kurlarını çeken component Kod:
unit DVKUR;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, URLMON, StdCtrls, ComCtrls;
type
TDVKUR = class(TComponent)
private
FTarih:TDate;
tdoviz:TStringList;
FUSDA,FEURA,FGBPA:Double;
FUSDS,FEURS,FGBPS:Double;
procedure AutoInitialize;
procedure AutoDestroy;
procedure SUSDA(Value:Double);
procedure SEURA(Value:Double);
procedure SGBPA(Value:Double);
procedure SUSDS(Value:Double);
procedure SEURS(Value:Double);
procedure SGBPS(Value:Double);
procedure STarih(Value:TDate);
{ Private declarations }
protected
{ Protected declarations }
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function execute(Tarihi:TDate):Boolean ;
{ Public declarations }
published
property Tarih : tdate read FTarih write STarih;
property USDA:Double READ FUSDA WRITE SUSDA;
property EURA:Double READ FEURA WRITE SEURA;
property GBPA:Double READ FGBPA WRITE SGBPA;
property USDS:Double READ FUSDS WRITE SUSDS;
property EURS:Double READ FEURS WRITE SEURS;
property GBPS:Double READ FGBPS WRITE SGBPS;
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Ramazan', [TDVKUR]);
end;
{ TDVKUR }
function VN(Deger:String):Double;
var sonuc:byte; veri:string; begin veri:=deger;
sonuc:=pos(',',veri); while sonuc<>0 do begin delete(veri,sonuc,1); sonuc:=pos(',',veri); end;
sonuc:=pos('.',veri); while sonuc<>0 do begin delete(veri,sonuc,1); insert(',',veri,sonuc); sonuc:=pos('.',veri); end;
Result:=StrToFloat(veri);
end;
function DownFile(Source: string): Boolean;
begin
try
Result := UrlDownloadToFile(nil, PChar(source), PChar('C:Program FilesTDVZ.HTM'), 0, nil) = 0;
except
Result := False;
end;
end;
procedure TDVKUR.AutoDestroy;begin tdoviz.Free;end;
procedure TDVKUR.AutoInitialize;begin tdoviz := TStringList.Create; FTarih:=Now(); end;
procedure TDVKUR.SEURA(Value: Double);begin FEURA:=Value;end;
procedure TDVKUR.SEURS(Value: Double);begin FEURS:=Value;end;
procedure TDVKUR.SGBPA(Value: Double);begin FGBPA:=Value;end;
procedure TDVKUR.SGBPS(Value: Double);begin FGBPS:=Value;end;
procedure TDVKUR.SUSDA(Value: Double);begin FUSDA:=Value;end;
procedure TDVKUR.SUSDS(Value: Double);begin FUSDS:=Value;end;
procedure TDVKUR.STarih(Value: TDate);begin FTarih:=Value;end;
constructor TDVKUR.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
AutoInitialize;
end;
destructor TDVKUR.Destroy;
begin
AutoDestroy;
inherited Destroy;
end;
function TDVKUR.execute(Tarihi:TDate): Boolean;
var x:integer;gunu:String;
begin
gunu:=DateToStr(Tarihi);
gunu:=copy(gunu,7,4)+copy(gunu,4,2)+'/'+copy(gunu,1,2)+copy(gunu,4,2)+copy(gunu,7,4);
Tarih:=Tarihi;
if DownFile('http://<a href=" Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir. then
begin { Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir. tdoviz.LoadFromFile('C:Program FilesTDVZ.HTM');
for x:=0 to 10 do
tdoviz.Delete(0);
try
for x:=0 to tdoviz.Count-1-18 do
tdoviz.Delete(18);
except
end;
for x:=0 to tdoviz.Count-1 do
begin
if (Trim(copy(tdoviz.Strings[x],1,7))='USD') OR (Trim(copy(tdoviz.Strings[x],1,7))='USD/TRY') THEN
begin
USDA:=VN(Trim(copy(tdoviz.Strings[x],37,12)));
USDS:=VN(Trim(copy(tdoviz.Strings[x],50,12)));
end;
if (Trim(copy(tdoviz.Strings[x],1,7))='EUR') OR (Trim(copy(tdoviz.Strings[x],1,7))='EUR/TRY') THEN
begin
EURA:=VN(Trim(copy(tdoviz.Strings[x],37,12)));
EURS:=VN(Trim(copy(tdoviz.Strings[x],50,12)));
end;
if (Trim(copy(tdoviz.Strings[x],1,7))='GBP') OR (Trim(copy(tdoviz.Strings[x],1,7))='GBP/TRY') THEN
begin
GBPA:=VN(Trim(copy(tdoviz.Strings[x],37,12)));
GBPS:=VN(Trim(copy(tdoviz.Strings[x],50,12)));
end;
end;
Result:=True;
end
else
Result:=False;
end;
end. |