How to Convert a String in a FOR Loop

Jan 21 2019 3:58 AM
Hallo Team,
 
I have a question for a web project. I need some tips to develop it.
I have to develop a printer program in C#, which GUI will be developped with JQuery.
For the printer program I opened a socket connection. 
Here some requisitions of the project:
 
I need to work on a ZPL string (because the printer works on a ZPL code), thats why I have: 
 
string ZPLString = "^FT70,230^A0N,60,60^FD01 0001 0001 0011^FS"
 
 and I have to build a counter for this piece of string 0011 which starts counting from 1 to 11 
 
that's why I set a variable  
 
string objectNumber = "0011";
 
 For the Counter I wrote a for loop
 
for (int i = 1; i < BranchOffice.StartObjectNumber; i++)
{
        byte[] sendBytes = Encoding.GetEncoding("Cp850").GetBytes(objectNumber);
        stream.Write(sendBytes, 0, sendBytes.Length);
}
 
we all know that in a for-loop thare are only conditions in int data type
but I actually need the string "0011" to let run through from 1 to 11 so that the program can print more tickets at the same time If I select for example 001 to 004 on the UI (because the User has got this printer program on its web portal).
 
Thats's the reason why I thought to convert the string like that:
 
int x = 0;
string objectNumber = "0001";
Int32.TryParse(objectNumber, out x);
 
so that I can count from 1 to 11 in the for loop but it doesnt work.
It prints only one ticket. 
 
Now my questions are:
 
1) how shall I use the converted string in this for-loop? 
 
2) Shall I  better implement the for-loop in JavaScript/JQuery rather then in C#?
 
I hope you can help me. I'm a beginner Software Developer and I still don't know which the best solution could be.
 
Thank you in advance.
Have a nice start in the week. 

Answers (2)