整数到字符串转换时出错
我正在 Windows XP 上使用 Delphi 7 进行编程。程序的这一部分正在为 opendialog
定义标题,我遇到了一个非常奇怪的问题。
出现错误的代码如下,
od_cap := 'Select data set ' + intToStr(n_data_sets);
其中 od_cap
是字符串,n_data_sets
是整数。出现的错误是地址 0040459a 处的 EAccessViolation...我已将问题范围缩小到由 inttostr
转换引起,因为当我有 od_cap 时它仍然崩溃:= inttostr(2)。更奇怪的是,第一次计算这条线时,它可以工作,但每次第二次都会崩溃。
我想不出任何原因,而且我没有足够的经验来知道可能导致这种情况的任何错误。我认为这就是您应该需要的所有信息,但请随时询问更多信息。
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 string 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IntToStr()
在转换期间不会引发 AV。更有可能发生的情况是od_cap
变量不是有效的String
变量,例如如果它是已释放对象的成员,那么当它被分配给。IntToStr()
does not raise an AV during conversion. What is more likely happening is theod_cap
variable is not a validString
variable, such as if it is a member of an object that has been freed, so an AV occurs when it is assigned to.