Lpad with zero's in vbscript

前端 未结 4 1328
死守一世寂寞
死守一世寂寞 2020-12-11 01:48

I\'m trying to pad a string with 0\'s to the left.The length of the output string should be 7. Here\'s my code :

inputstr = \"38\"
in = string(7 - Len(input         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-11 02:30

    in is a reserved word so can't be used as a variable name and you must pass a string "0" not an integer 0, so:

    inputStr = "38"
    result = string(7 - Len(inputStr), "0") & inputStr
    
    msgbox result
    

提交回复
热议问题