troubleshooting Question

Removing leading zero's from VBScript counter

Avatar of mitokondrium
mitokondrium asked on
VB Script
10 Comments2 Solutions57 ViewsLast Modified:
I'm trying to make a VBScript produce a counter with this format: YY/nn (16/1 - 16/2).
It has to handle numbers up to 4 characters (16/100, 16/1055).

I have found this code, who does the job, but it displays leading zeroes (16/0001), how can i remove the leading zeroes from the output and meet the requirements?

Dim yy, nn
yy = Right(Year(Date()),2)
If isnull(LastUsed) or (LastUsed="") Then
      nn = 1
ElseIf Left(LastUsed,2)=yy Then      
      nn = CInt(Right(LastUsed,4)) + 1
      nn = 1
End If
Output = yy & "/" & Right("0000" & nn,4)

***CODE END***
Join our community to see this answer!
Unlock 2 Answers and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros