开发者

An error with integer to string conversion

开发者 https://www.devze.com 2023-04-12 13:14 出处:网络
I am programming in Delphi 7 on Windows XP. This part of the program is defining a caption for the opendialog and I have a really strange problem.

I am programming in Delphi 7 on Windows XP. This part of the program is defining a caption for the opendialog and I have a really strange problem.

The code with the error is as below

od_cap := 'Select data set ' + intToStr(n_data_sets);

where od_cap is a st开发者_高级运维ring and n_data_sets is an integer. The error that arises is EAccessViolation at address 0040459a... I have narrowed the problem down to being caused by the inttostr conversion because it still crashes when I have od_cap := inttostr(2). The more strange thing is that first time it computes this line, it works but then crashes the 2nd time round every time.

I cannot think of any reason why this might be and I am not experienced enough to know any bugs that might cause this. I think this is all the information you should need but feel free to ask for more.


IntToStr() does not raise an AV during conversion. What is more likely happening is the od_cap variable is not a valid String variable, such as if it is a member of an object that has been freed, so an AV occurs when it is assigned to.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号