Trying to use FormatNumber with a decimal type from an MS SQL Database. 
Author Message
 Trying to use FormatNumber with a decimal type from an MS SQL Database.

It doesn't work.

This is my problem although in MS SQL 7, the field is Decimal type with a
Scale of 4.  If I type 5 into a SQL Field, it doesn't pad the zeros.  So I
need to pad the zeros in the VBScript.  But FormatNumber won't work, and
there doesn't appear to be a FormatDecimal type.

Is there function to convert this decimal type to a number type so
FormatNumber can do the job.

Any ideas, thanks..

Peter DeSimone



Fri, 10 May 2002 03:00:00 GMT  
 Trying to use FormatNumber with a decimal type from an MS SQL Database.

Try the CLng() function...

--
Michael Harris

  It doesn't work.

  This is my problem although in MS SQL 7, the field is Decimal type with a
  Scale of 4.  If I type 5 into a SQL Field, it doesn't pad the zeros.  So I
  need to pad the zeros in the vbscript.  But FormatNumber won't work, and
  there doesn't appear to be a FormatDecimal type.

  Is there function to convert this decimal type to a number type so
  FormatNumber can do the job.

  Any ideas, thanks..

  Peter DeSimone



Fri, 10 May 2002 03:00:00 GMT  
 Trying to use FormatNumber with a decimal type from an MS SQL Database.

CLng doesn't help as I need the decimal that is there.

My problem is that I have a value of 5 in the database that is configured as a decimal in SQL with 2 decimal places, but SQL won't save it as 5.00.  I need it to display as 5.00.  But if the number is 6.5.  Then I need 6.50 to show up.

Any more ideas.

Peter DeSimone


  Try the CLng() function...

  --
  Michael Harris

    It doesn't work.

    This is my problem although in MS SQL 7, the field is Decimal type with a
    Scale of 4.  If I type 5 into a SQL Field, it doesn't pad the zeros.  So I
    need to pad the zeros in the vbscript.  But FormatNumber won't work, and
    there doesn't appear to be a FormatDecimal type.

    Is there function to convert this decimal type to a number type so
    FormatNumber can do the job.

    Any ideas, thanks..

    Peter DeSimone



Fri, 10 May 2002 03:00:00 GMT  
 Trying to use FormatNumber with a decimal type from an MS SQL Database.

Then try CSng() or CDbl()...

When you query the variable with TypeName() or VarType() what do you get?  One will "recognize" VT_DECIMAL types (I don't remember right now which one - it's noted in the "VBScript Programmer's Reference" from Wrox Press)...  If it's TypeName then the string will be "Decimal".  If it's VarType then the value will be 14 (vbDecimal = 14).  For whatever reason, VBScript doesn't seem to fully support vbDecimal as a variant subtype and only one of the type functions recognizes it.  But I've seen cases where the conversion functions can convert it ok...

--
Michael Harris


  CLng doesn't help as I need the decimal that is there.

  My problem is that I have a value of 5 in the database that is configured as a decimal in SQL with 2 decimal places, but SQL won't save it as 5.00.  I need it to display as 5.00.  But if the number is 6.5.  Then I need 6.50 to show up.

  Any more ideas.

  Peter DeSimone


    Try the CLng() function...

    --
    Michael Harris

      It doesn't work.

      This is my problem although in MS SQL 7, the field is Decimal type with a
      Scale of 4.  If I type 5 into a SQL Field, it doesn't pad the zeros.  So I
      need to pad the zeros in the vbscript.  But FormatNumber won't work, and
      there doesn't appear to be a FormatDecimal type.

      Is there function to convert this decimal type to a number type so
      FormatNumber can do the job.

      Any ideas, thanks..

      Peter DeSimone



Fri, 10 May 2002 03:00:00 GMT  
 Trying to use FormatNumber with a decimal type from an MS SQL Database.

It is a vbdecimal.  #14.  I already checked that.

I will review the CSing and CDbl functions.

Thanks..

Peter

  Then try CSng() or CDbl()...

  When you query the variable with TypeName() or VarType() what do you get?  One will "recognize" VT_DECIMAL types (I don't remember right now which one - it's noted in the "VBScript Programmer's Reference" from Wrox Press)...  If it's TypeName then the string will be "Decimal".  If it's VarType then the value will be 14 (vbDecimal = 14).  For whatever reason, VBScript doesn't seem to fully support vbDecimal as a variant subtype and only one of the type functions recognizes it.  But I've seen cases where the conversion functions can convert it ok...

  --
  Michael Harris


    CLng doesn't help as I need the decimal that is there.

    My problem is that I have a value of 5 in the database that is configured as a decimal in SQL with 2 decimal places, but SQL won't save it as 5.00.  I need it to display as 5.00.  But if the number is 6.5.  Then I need 6.50 to show up.

    Any more ideas.

    Peter DeSimone


      Try the CLng() function...

      --
      Michael Harris

        It doesn't work.

        This is my problem although in MS SQL 7, the field is Decimal type with a
        Scale of 4.  If I type 5 into a SQL Field, it doesn't pad the zeros.  So I
        need to pad the zeros in the vbscript.  But FormatNumber won't work, and
        there doesn't appear to be a FormatDecimal type.

        Is there function to convert this decimal type to a number type so
        FormatNumber can do the job.

        Any ideas, thanks..

        Peter DeSimone



Sat, 11 May 2002 03:00:00 GMT  
 Trying to use FormatNumber with a decimal type from an MS SQL Database.
VBScript doesn't directly support the Decimal type, no.  Mike is right
though -- like all unsupported types, frequently VBScript can just pass them
on to operating system functions that do support them.  The underlying
variant coercion code is actually in the operating system in many cases.

Eric


Then try CSng() or CDbl()...

When you query the variable with TypeName() or VarType() what do you get?
One will "recognize" VT_DECIMAL types (I don't remember right now which
one - it's noted in the "VBScript Programmer's Reference" from Wrox
Press)...  If it's TypeName then the string will be "Decimal".  If it's
VarType then the value will be 14 (vbDecimal = 14).  For whatever reason,
VBScript doesn't seem to fully support vbDecimal as a variant subtype and
only one of the type functions recognizes it.  But I've seen cases where the
conversion functions can convert it ok...

--
Michael Harris


CLng doesn't help as I need the decimal that is there.

My problem is that I have a value of 5 in the database that is configured as
a decimal in SQL with 2 decimal places, but SQL won't save it as 5.00.  I
need it to display as 5.00.  But if the number is 6.5.  Then I need 6.50 to
show up.

Any more ideas.

Peter DeSimone


Try the CLng() function...

--
Michael Harris

It doesn't work.

This is my problem although in MS SQL 7, the field is Decimal type with a
Scale of 4.  If I type 5 into a SQL Field, it doesn't pad the zeros.  So I
need to pad the zeros in the vbscript.  But FormatNumber won't work, and
there doesn't appear to be a FormatDecimal type.

Is there function to convert this decimal type to a number type so
FormatNumber can do the job.

Any ideas, thanks..

Peter DeSimone



Sat, 11 May 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Trying to use FormatNumber with a decimal type from an MS SQL Database.

2. VBScript- SQL Query of MS SQL 7 Database

3. Weird ASP error when trying to add a new record to a MS Access database

4. Help..Using VB6 Data Control to access MS SQL Server7 Database

5. Decimal data types in ADO/SQL

6. SQL Server Decimal type

7. MS SQL and ADC - Decimal Precision Problems

8. MS Access and SQL 7.0 databases with VBScript

9. Interdev/scripting/MS SQL Database

10. access to MS sql database with WSH ??

11. How to set the decimal places in MS Access 97 using VB

12. How to set Decimal Places of a MS Access field using VB

 

 
Powered by phpBB® Forum Software