3

I am using Delphi 2010 and have a program which keeps generating an error dialog box stating

'' is not a valid floating point value

How do I get delphi to show me the line that generated that error?

robert
  • 51
  • 1
  • 4

2 Answers2

4

The easiest way to solve this is to run under the debugger and have it configured to Notify on language exceptions, Tools | Options:

enter image description here

Ignore the big list of exceptions to ignore that come from my own codebase. Just make sure the checkbox I have highlighted is marked.

Then when you run your program, it will stop at the line that causes the exception.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
0

Search your code for StrToFloat function. This function raises an exception if the parameter is an empty string. You can replace the function call with:

if Trim(StrV) = '' then StrV := '0.0'; f := StrToFloat(StrV);

Experience
  • 98
  • 8
  • Lifesaver - what a star; I was assuming that the problem was coming from how I was using Font.Color and Brush.Color in a dbgrids OnDrawColumnCell method, but it was actually arising within the code for an onform teechart linked to a database. Many thanks. – robert Feb 23 '11 at 11:41
  • 1
    Or just use `StrToFloatDef(StrV, 0.0)` instead. That saves the function call to Trim and separate string assignment. `StrToFloatDef` is in SysUtils. You might also want to know about `StrToIntDef` in that unit also. – Ken White Feb 23 '11 at 13:56