Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

The value '' cannot be converted to a number.

Guest
Sep 08, 2011 Sep 08, 2011

Has anyone encountered this error?  i am dividing two values to get a percentage.  It works except at some point I recieve this error:

The value '' cannot be converted to a number.

11.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Sep 08, 2011 Sep 08, 2011

Use isNumeric() to verify that all the variables involved contain numbers.

Translate
Advocate ,
Sep 08, 2011 Sep 08, 2011

Yes, when one of the values in a mathematical operation is an empty string you will get this error. At some point in your code execution one of your values is ending up as an empty string.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 08, 2011 Sep 08, 2011

I' tried the following replace function, <cfset txtDeptList = replace (txtDeptList, "''", "", "ALL")>, but I've not had any success.  Do you have any suggestions on how to eliminate the error.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 08, 2011 Sep 08, 2011

Use isNumeric() to verify that all the variables involved contain numbers.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 08, 2011 Sep 08, 2011

Thank you, something i should have thought of.  The error went away!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 09, 2011 Sep 09, 2011
LATEST

One way to validate that you truly have numbers for your variables is to use the ColdFusion IsValid() function, for example, if you want to work only with integer numbers, you can use the function in the following way:

<cfif IsValid("integer",variables.a) and IsValid("integer", variables.b)>

   <cfset Result = variables.a + variables.b>

</cfif>

IsValid works with alot of different data types, including verifying proper emails and also verifying a range of numbers.

You can find more information about this useful function at the adobe livedocs at the following URL:

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_in-k_37.html

Most of the web programming languages, like ASP.NET and others, have such functions for validating data types.

Hope this helps.

Michael G. Workman

michael.g.workman@gmail.com

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources