-1

I need to convert number to string that have zeros in front because I have to report it on an Excel sheet, with vbscript language. iF i use the function Cstr, the zeros are removed

objtemp.setvar "num_code", rs("code")

It doesn't work

1 Answers1

0

Concatenate ("&") a sequence of "0"s and your number, take the right part:

>> SetLocale "en_us"
>> For Each n In Array(4711, 47.11, "123", 0)
>>     WScript.Echo Right(String(10, "0") & n, 10)
>> Next
>>
0000004711
0000047.11
0000000123
0000000000

To force Excel to treat the data as String, format the column/cell as Text and/or prepend a '.

Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96