目前,我正在使用
Cells(i, 6) & ("-000") & (q)
生成我的代码。但我意识到,当q
成为2位数的int(即11
)时,输出就像16-00011
,我不想要。我希望输出像16-0011
。
答案 0 :(得分:0)
使用Format
:
Dim myOutput as String
myOutput = Cells(i, 6) & "-" & Format(q, "0000")
' If Cells(i, 6) = 16, and q = 11 then
' >> myOutput = "16-0011"
' If Cells(i, 6) = 16, and q = 9 then
' >> myOutput = "16-0009"
Format
的文档:
https://msdn.microsoft.com/en-us/library/office/gg251755.aspx