我正在尝试计算以下方案的每月付款:
5,000美元借款3年,每月复合8.00%,期末1000美元到期.
/*
From Math.pas
function Payment(Rate: Extended;
NPeriods: Integer;
const PresentValue: Extended;
const FutureValue: Extended;
PaymentTime: TPaymentTime): Extended;
*/
var
Pmt : Extended;
begin
Pmt := Payment(0.08/12,36,5000,1000,ptEndOfPeriod);
Edit1.Text := FloatToStr(Pmt);
end
Run Code Online (Sandbox Code Playgroud)
结果= -181.351526101918
结果正确,但它是否定的.
为什么Payment函数的结果返回负数?
我使用以下内容创建Windows计时器
FHandle := SetTimer(0, 0, 1000, TFNTimerProc(@TMyClass.MyMethod));
Run Code Online (Sandbox Code Playgroud)
该线程是否显示在Delphi"Threads"窗口中.如果是,我如何获得此线程ID?
我有一个应用程序加载CAD数据(自定义格式),从本地文件系统指定绘图的绝对路径或从数据库.
通过将图纸标识符作为参数的库函数来实现数据库访问.
标识符的格式类似ABC 01234T56-T,而我的路径是典型的Windows路径(例如x:\Data\cadfiles\cadfile001.bin).
我想编写一个包装器函数将一个String作为一个参数,它可以是一个路径或一个标识符,它调用适当的函数来加载我的数据.
像这样:
Function CadLoader(nameOrPath : String):TCadData;
Run Code Online (Sandbox Code Playgroud)
我的问题:我怎样才能优雅地决定我的字符串是一个idnetifier还是文件的路径?使用正则表达式?或者只搜索'\'和':',它们没有出现在标识符中?
在我的应用程序中,我创建了TList类型列表,用于存储整数或双精度:
TKList<T> = class
private
FItems: TList<T>;
function GetItem(Index: Integer): T;
procedure SetItem(Index: Integer; const Value: T);
function GetMaxValue(): T;
function GetMinValue(): T;
public
constructor Create; overload;
constructor Create(const AKList: TKList<T>); overload;
destructor Destroy; override;
procedure Assign(const AKList: TKList<T>);
function Add(const AValue: T): Integer;
procedure Clear;
function Count: Integer;
procedure Invert;
function ToString: string; override;
function Info: string;
property Values[Index: Integer]: T read GetItem write SetItem; default;
end;
Run Code Online (Sandbox Code Playgroud)
如何实现Invert()过程来反转泛型List中的值?
提前致谢.
// interface
iccItem =
class
ID : String;
DATA : Variant;
constructor Create( _id : String; _data : Variant);
end;
iccDynamicObject =
class
private
FItems : TList;
function locate( _id : String) : iccItem;
public
constructor Create();
destructor Destroy(); override;
public
procedure define( _id : String; _dta : Variant);
//function get( _ndx : DWORD) : Variant; overload;// link to original data
function get( _id : String) : Variant; overload;
public
property Items[_id : String] : Variant read get write define; …Run Code Online (Sandbox Code Playgroud) 自从我写了一段C代码以来,我已经很久了.有谁知道如何将这段代码翻译成Delphi 2010?
char * pAlignedBuf = (char *) ((int(buf) + 7) & ~7);
Run Code Online (Sandbox Code Playgroud)
buf在哪里char * buf.
我知道,char *是Pchar的,但我不知道是什么&和~7是.
如何将两个VCL组件合并在一起,以便可以访问它们的两个属性?
例如,我想将a TImage和a 合并TPanel为一个,我要求它TPanel是基本组件,因此TImage将是子项TPanel.
是否有可能做到这一点?
我一直试图通过Component> New VCL Component在Delphi 2010中做到这一点,但是当我需要可视组件时它会创建非可视组件.
我该怎么做才能改变这个?
如果我知道整数值的枚举,如何获得字符串表示?
type
MyEnum = (tmp_one, tmp_two, tmp_three);
const
MyTypeNames: array[tmp_one..tmp_three] of string = ('One', 'Two', 'Three');
Run Code Online (Sandbox Code Playgroud) 我刚刚发现了仿制药(我知道这太惊人了!)并立刻爱上了它...直到我发现Delphi 2010(安装了更新4和5)失败并带有可怕的[DCC Fatal Error] F2084 Internal Error: L1737消息,如果我有这个代码:
// Global array of list
IDsList : Array [1..5] Of TDictionary<Int64, Int64>;
function MyProc;
var
i : Integer;
Enum : TDictionary<Int64, Int64>.TPairEnumerator;
begin
// ...
Enum := IDsList[i].GetEnumerator;
while Enum.MoveNext do
begin
// ...
end;
end;
Run Code Online (Sandbox Code Playgroud)
确切地说,除非我评论这一行,否则Delphi无法编译 Enum := IDsList[i].GetEnumerator;
使用数组大大简化了我的代码,有没有办法避免这个L1737错误消息?
PS.我不是Delphi的新手,只有泛型!
我做了:
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
DataTable.qOrders.Next;
end;
Run Code Online (Sandbox Code Playgroud)
它的工作原理,但问题是当我点击按钮到达最后一条记录时,按钮没有被禁用,就像在a TDBNavigator.
我是如何进行TSpeedButton禁用并自动启用的TDBNavigator?
delphi ×10
delphi-2010 ×10
generics ×3
c ×1
delphi-7 ×1
delphi-xe2 ×1
financial ×1
math ×1
regex ×1
timer ×1
translation ×1
variant ×1