我编写一个声音调的程序,执行结束时会报错,Project Project1.exe raised exception class EInvalidPointer with message 'Invalid pointer opertion'.Process stopped.Use Step or Run to continue.
读出交费金额
我有制作资源文件代码如下:unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Mmsystem, StdCtrls;type
TForm1 = class(TForm)
Button2: TButton;
Button4: TButton;
Edit1: TEdit; procedure Button2Click(Sender: TObject); procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
{$R sounds.res} //个人制作的资源文件
procedure TForm1.Button2Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
l_str:string;
l_c1,l_c2,l_c3,l_c4,l_c5,l_c6,l_c7:String;
i:integer;
Num:real;
l_cc:String;
l_Currency:Currency;
begin
l_currency:=StrToCurr(Edit1.Text);
l_str:=CurrToStr(l_currency);
Num:=StrToFloat(l_str);
{0~9.99数字读取}
if(Num<10) and (Num>=0)then
begin
l_c1:='c'+l_str[1];
l_c3:='c'+l_str[3];
l_c4:='c'+l_str[4];
if not ( l_str[4] in ['0'..'9']) then
begin
l_str[4]:='0';
end;
if not (l_str[3] in ['0'..'9']) then
begin
l_str[3]:='0';
end;
if StrToInt(l_str[1])<>0 then //第一位
begin
PlaySound(Pchar(l_c1),Hinstance,SND_RESOURCE OR SND_SYNC);
end
else
begin
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
PlaySound('c17',Hinstance,SND_RESOURCE OR SND_SYNC); //点.wav
if StrToInt(l_str[3])<>0 then //第三位
begin
PlaySound(Pchar(l_c3),Hinstance,SND_RESOURCE OR SND_SYNC); //第三位
end
else
begin
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
if StrToInt(l_str[4])<>0 then //第四位
begin
PlaySound(Pchar(l_c4),Hinstance,SND_RESOURCE OR SND_SYNC); //第四位
end
else
begin
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav
end;
{10~99.99的数字读取 Eg:99.10}
if (Num>=10) and (Num<100) then {10~100}
begin
l_c1:='c'+ l_str[1]; //第一位
l_c2:='c'+ l_str[2]; //第二位
l_c4:='c'+ l_str[4]; //第四位
l_c5:='c'+ l_str[5]; //第五位
if not ( l_str[4] in ['0'..'9']) then
begin
l_str[4]:='0';
end;
if not (l_str[5] in ['0'..'9']) then
begin
l_str[5]:='0';
end;
PlaySound(Pchar(l_c1),Hinstance,SND_RESOURCE OR SND_SYNC); //第一位
PlaySound('c11',Hinstance,SND_RESOURCE OR SND_SYNC); //拾
if StrToInt(l_str[2])<>0 then
begin
PlaySound(Pchar(l_c2),Hinstance,SND_RESOURCE OR SND_SYNC); //第二位
end;
PlaySound('c17',Hinstance,SND_RESOURCE OR SND_SYNC); //点.wav
if StrToInt(l_str[4])<>0 then //第四位
begin
PlaySound(Pchar(l_c4),Hinstance,SND_RESOURCE OR SND_SYNC);
end
else
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
if StrToInt(l_str[5])<>0 then //第五位
begin
PlaySound(Pchar(l_c5),Hinstance,SND_RESOURCE OR SND_SYNC);
end
else
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav
end;
{100~999.99}
if (Num>=100) and (Num<1000) then
begin
l_c1:='c'+l_str[1]; //百位数字
l_c2:='c'+l_str[2]; //十位数字
l_c3:='c'+l_str[3]; //个位数字
l_c5:='c'+l_str[5]; //十分位数字
l_c6:='c'+l_str[6]; //百分位数字
if not ( l_str[6] in ['0'..'9']) then
begin
l_str[6]:='0';
end;
if not (l_str[5] in ['0'..'9']) then
begin
l_str[5]:='0';
end;
PlaySound(Pchar(l_c1),Hinstance,SND_RESOURCE OR SND_SYNC); //第一位
PlaySound('c12',Hinstance,SND_RESOURCE OR SND_SYNC); //佰.wav
if StrToInt(l_str[2])<>0 then
begin
PlaySound(Pchar(l_c2),Hinstance,SND_RESOURCE OR SND_SYNC); //第二位
PlaySound('c11',Hinstance,SND_RESOURCE OR SND_SYNC); //拾
end
else
begin
if StrToInt(l_str[3])<>0 then
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
if StrToInt(l_str[3])<>0 then
begin
PlaySound(Pchar(l_c3),Hinstance,SND_RESOURCE OR SND_SYNC); //第三位
end;
PlaySound('c17',Hinstance,SND_RESOURCE OR SND_SYNC); //点.wav
if StrToInt(l_str[5])<>0 then
begin
PlaySound(Pchar(l_c5),Hinstance,SND_RESOURCE OR SND_SYNC); //第五位
end
else
begin
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
if StrToInt(l_str[6])<>0 then //第六位
begin
PlaySound(Pchar(l_c6),Hinstance,SND_RESOURCE OR SND_SYNC);
end
else
begin
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav
end;
{1000~9999.99}
if (Num>=1000) and (Num<10000) then
begin
l_c1:='c'+l_str[1]; //仟位
l_c2:='c'+l_str[2]; //百位
l_c3:='c'+l_str[3]; //十位
l_c4:='c'+l_str[4]; //个位
l_c6:='c'+l_str[6]; //十分位
l_c7:='c'+l_str[7]; //百分位
if not ( l_str[6] in ['0'..'9']) then
begin
l_str[6]:='0';
end;
if not (l_str[7] in ['0'..'9']) then
begin
l_str[7]:='0';
end;
PlaySound(Pchar(l_c1),Hinstance,SND_RESOURCE OR SND_SYNC); //第一位
PlaySound('c13',Hinstance,SND_RESOURCE OR SND_SYNC); //仟.wav
if StrToInt(l_str[2])<>0 then
begin
PlaySound(Pchar(l_c2),Hinstance,SND_RESOURCE OR SND_SYNC); //第二位
PlaySound('c12',Hinstance,SND_RESOURCE OR SND_SYNC); //佰.wav
end
else
begin
if (StrToInt(l_str[3])<>0) or (StrToInt(l_str[4])<>0) then
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
if StrToInt(l_str[3])<>0 then
begin
PlaySound(Pchar(l_c3),Hinstance,SND_RESOURCE OR SND_SYNC); //十位
PlaySound('c11',Hinstance,SND_RESOURCE OR SND_SYNC); //拾
end
else
begin
if StrToInt(l_str[4])<>0 then
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
if StrToInt(l_str[4])<>0 then
begin
PlaySound(Pchar(l_c4),Hinstance,SND_RESOURCE OR SND_SYNC); //个位
end;
PlaySound('c17',Hinstance,SND_RESOURCE OR SND_SYNC); //点.wav
if StrToInt(l_str[6])<>0 then
begin
PlaySound(Pchar(l_c6),Hinstance,SND_RESOURCE OR SND_SYNC); //十分位
end
else
begin
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
if StrToInt(l_str[7])<>0 then //白分位
begin
PlaySound(Pchar(l_c7),Hinstance,SND_RESOURCE OR SND_SYNC);
end
else
begin
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC); //00.wav
end;
PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav
end;
// sleep(1000);
end;end.
读出交费金额
我有制作资源文件代码如下:unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Mmsystem, StdCtrls;type
TForm1 = class(TForm)
Button2: TButton;
Button4: TButton;
Edit1: TEdit; procedure Button2Click(Sender: TObject); procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
{$R sounds.res} //个人制作的资源文件
procedure TForm1.Button2Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
l_str:string;
l_c1,l_c2,l_c3,l_c4,l_c5,l_c6,l_c7:String;
i:integer;
Num:real;
l_cc:String;
l_Currency:Currency;
begin
l_currency:=StrToCurr(Edit1.Text);
l_str:=CurrToStr(l_currency);
Num:=StrToFloat(l_str);
{0~9.99数字读取}
if(Num<10) and (Num>=0)then
begin
l_c1:='c'+l_str[1];
l_c3:='c'+l_str[3];
l_c4:='c'+l_str[4];
if not ( l_str[4] in ['0'..'9']) then
begin
l_str[4]:='0';
end;
if not (l_str[3] in ['0'..'9']) then
begin
l_str[3]:='0';
end;
if StrToInt(l_str[1])<>0 then //第一位
begin
PlaySound(Pchar(l_c1),Hinstance,SND_RESOURCE OR SND_SYNC);
end
else
begin
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
PlaySound('c17',Hinstance,SND_RESOURCE OR SND_SYNC); //点.wav
if StrToInt(l_str[3])<>0 then //第三位
begin
PlaySound(Pchar(l_c3),Hinstance,SND_RESOURCE OR SND_SYNC); //第三位
end
else
begin
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
if StrToInt(l_str[4])<>0 then //第四位
begin
PlaySound(Pchar(l_c4),Hinstance,SND_RESOURCE OR SND_SYNC); //第四位
end
else
begin
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav
end;
{10~99.99的数字读取 Eg:99.10}
if (Num>=10) and (Num<100) then {10~100}
begin
l_c1:='c'+ l_str[1]; //第一位
l_c2:='c'+ l_str[2]; //第二位
l_c4:='c'+ l_str[4]; //第四位
l_c5:='c'+ l_str[5]; //第五位
if not ( l_str[4] in ['0'..'9']) then
begin
l_str[4]:='0';
end;
if not (l_str[5] in ['0'..'9']) then
begin
l_str[5]:='0';
end;
PlaySound(Pchar(l_c1),Hinstance,SND_RESOURCE OR SND_SYNC); //第一位
PlaySound('c11',Hinstance,SND_RESOURCE OR SND_SYNC); //拾
if StrToInt(l_str[2])<>0 then
begin
PlaySound(Pchar(l_c2),Hinstance,SND_RESOURCE OR SND_SYNC); //第二位
end;
PlaySound('c17',Hinstance,SND_RESOURCE OR SND_SYNC); //点.wav
if StrToInt(l_str[4])<>0 then //第四位
begin
PlaySound(Pchar(l_c4),Hinstance,SND_RESOURCE OR SND_SYNC);
end
else
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
if StrToInt(l_str[5])<>0 then //第五位
begin
PlaySound(Pchar(l_c5),Hinstance,SND_RESOURCE OR SND_SYNC);
end
else
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav
end;
{100~999.99}
if (Num>=100) and (Num<1000) then
begin
l_c1:='c'+l_str[1]; //百位数字
l_c2:='c'+l_str[2]; //十位数字
l_c3:='c'+l_str[3]; //个位数字
l_c5:='c'+l_str[5]; //十分位数字
l_c6:='c'+l_str[6]; //百分位数字
if not ( l_str[6] in ['0'..'9']) then
begin
l_str[6]:='0';
end;
if not (l_str[5] in ['0'..'9']) then
begin
l_str[5]:='0';
end;
PlaySound(Pchar(l_c1),Hinstance,SND_RESOURCE OR SND_SYNC); //第一位
PlaySound('c12',Hinstance,SND_RESOURCE OR SND_SYNC); //佰.wav
if StrToInt(l_str[2])<>0 then
begin
PlaySound(Pchar(l_c2),Hinstance,SND_RESOURCE OR SND_SYNC); //第二位
PlaySound('c11',Hinstance,SND_RESOURCE OR SND_SYNC); //拾
end
else
begin
if StrToInt(l_str[3])<>0 then
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
if StrToInt(l_str[3])<>0 then
begin
PlaySound(Pchar(l_c3),Hinstance,SND_RESOURCE OR SND_SYNC); //第三位
end;
PlaySound('c17',Hinstance,SND_RESOURCE OR SND_SYNC); //点.wav
if StrToInt(l_str[5])<>0 then
begin
PlaySound(Pchar(l_c5),Hinstance,SND_RESOURCE OR SND_SYNC); //第五位
end
else
begin
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
if StrToInt(l_str[6])<>0 then //第六位
begin
PlaySound(Pchar(l_c6),Hinstance,SND_RESOURCE OR SND_SYNC);
end
else
begin
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav
end;
{1000~9999.99}
if (Num>=1000) and (Num<10000) then
begin
l_c1:='c'+l_str[1]; //仟位
l_c2:='c'+l_str[2]; //百位
l_c3:='c'+l_str[3]; //十位
l_c4:='c'+l_str[4]; //个位
l_c6:='c'+l_str[6]; //十分位
l_c7:='c'+l_str[7]; //百分位
if not ( l_str[6] in ['0'..'9']) then
begin
l_str[6]:='0';
end;
if not (l_str[7] in ['0'..'9']) then
begin
l_str[7]:='0';
end;
PlaySound(Pchar(l_c1),Hinstance,SND_RESOURCE OR SND_SYNC); //第一位
PlaySound('c13',Hinstance,SND_RESOURCE OR SND_SYNC); //仟.wav
if StrToInt(l_str[2])<>0 then
begin
PlaySound(Pchar(l_c2),Hinstance,SND_RESOURCE OR SND_SYNC); //第二位
PlaySound('c12',Hinstance,SND_RESOURCE OR SND_SYNC); //佰.wav
end
else
begin
if (StrToInt(l_str[3])<>0) or (StrToInt(l_str[4])<>0) then
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
if StrToInt(l_str[3])<>0 then
begin
PlaySound(Pchar(l_c3),Hinstance,SND_RESOURCE OR SND_SYNC); //十位
PlaySound('c11',Hinstance,SND_RESOURCE OR SND_SYNC); //拾
end
else
begin
if StrToInt(l_str[4])<>0 then
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
if StrToInt(l_str[4])<>0 then
begin
PlaySound(Pchar(l_c4),Hinstance,SND_RESOURCE OR SND_SYNC); //个位
end;
PlaySound('c17',Hinstance,SND_RESOURCE OR SND_SYNC); //点.wav
if StrToInt(l_str[6])<>0 then
begin
PlaySound(Pchar(l_c6),Hinstance,SND_RESOURCE OR SND_SYNC); //十分位
end
else
begin
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
end;
if StrToInt(l_str[7])<>0 then //白分位
begin
PlaySound(Pchar(l_c7),Hinstance,SND_RESOURCE OR SND_SYNC);
end
else
begin
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC); //00.wav
end;
PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav
end;
// sleep(1000);
end;end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货