Cint Formatting in Classic ASP

0
Good afternoon. Guys, I'm having a doubt in formatting ...

In my table, I have a column with nchar data (4) (before it was nvarchar (4), but gave in the same), in the form users choose in a select to be able to fill and send to the table. >

In this select, I have for example the data "250", "1166", "2130" when I make a report on my web page (in asc), and I ask to sort, in ascending order, the data of this column .. the 250 stays after 1166, as if it were "2500", but in fact it should appear before , since the 250 should be considered as "0250".

I put, in my ASC file, to format as formatnumber (Cint (data), "0000")

but it did not work.

Does anyone know how to fix it?

Thank you

    
asked by anonymous 08.08.2018 / 21:15

1 answer

1

The problem is that you are using an invalid syntax for the formatnumber function.

What you have to do is add a PAD function like this:

Function PadDigits(val, digits)
  PadDigits = Right(String(digits,"0") & val, digits)
End Function

Then just use it this way:

PadDigits(dados,4)
    
08.08.2018 / 21:53