Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding 1 to 0001

Status
Not open for further replies.

99mel

Programmer
Oct 18, 1999
379
GB
Can anyone help me with this?<br><br>Simply the question is the subject.&nbsp;&nbsp;I'm wanting to add 1 onto the number 0001 resulting in th value becoming 0002.&nbsp;&nbsp;Obviousely when adding a plain 1 it gets rid of the preceding zeros and becomes 2.<br>I need to preceding &quot;000&quot; so the biggest number that it can go to it 9999.<br><br>Thanks for any help<br>
 
You will have to convert your result to a string... look at this sample.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Dim i As Integer<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim s As String<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;i = 2<br>&nbsp;&nbsp;&nbsp;&nbsp;s = Format(CStr(i), &quot;000#&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;MsgBox s<br><br>Hope this helps.<br>Paul<br>
 
? Format(0001 + 1, &quot;00000&quot;)<br>00002<br><br>or any number of variations on the theme of &quot;FORMAT&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top