C# StringBuilder: How to manipulate a string into counter?

Feb 4 2019 5:04 AM
Dear Team,
 
I need to manipulate the following StringBuilder (from a ZPL Printer Code):
 
 StringBuilder objectNumber = new StringBuilder("0001");
 
because I habe a GUI and on it there are 2 input fields:
 
- a StartObjectNumber (as integer instatiated), which starts from "0001"
- a  EndObjectNumber (as integer instatiated), which for example ends with "9999"
 
that's why it must count from "0001" to "9999" so that the programm prints the following tickets:
 
"0001", "0002", "0003" 
 
Question: shall I somehow convert objectNumber in integer? So that I can count from 0001 to 9999?
 
Here my code:
 
StringBuilder objectNumber = new StringBuilder("0001");
for (int i = BranchOffice.StartObjectNumber; i < BranchOffice.EndObjectNumber; i++)
ZPLString =
"^XA" +
"^PON" +
"^LH0,0" +
"^CI13^LRY" +
"^FT110,150^BY2^BCN,100,N,N,N^FD01000100010011^FS" +
"^FT70,230^A0N,60,60^FD01 0001 0001 " + objectNumber + "^FS" +
"^PR4" +
"^XZ";
byte[] sendBytes = Encoding.GetEncoding("Cp850").GetBytes(ZPLString);
stream.Write(sendBytes, 0, sendBytes.Length);
}
 
This code makes me only print more tickets but the content "0001" doesnt change.
I would like to print more tickets as the programm already does but it must count from "0001" to "9999".
I hope you can help m3.
Thank you in advance 

Answers (2)