Excel 导出经典 Ap 前导零

Excel Export Classic Ap Leading Zeros

我正在尝试将前导零添加到我的 excel 导出文件中,但它一直在删除我的零。

dteThisDob = rs("dob")
strThisDobYear = year(dteThisDob)
strThisDobMonth = right("0" & month(dteThisDob),2)
strThisDobDay = right("0" & day(dteThisDob),2)
strDob = strThisDobMonth & strThisDobDay & strThisDobYear 

这给我 excel 3041975 中的输出。 我要找的是03041975

您可以通过在字符串前加上 TAB 字符来强制 Excel 不将字符串转换为数值(并通过这样做删除前导零)。

strDob = Chr(9) & strThisDobMonth & strThisDobDay & strThisDobYear