I have a problem cutting this string string
. I get it by scanner, but the scanner pulls out prefixes and suffixes and I want to eliminate them. The code works for me with a string like this ~200|12345678~
and returns 12345678
. But sometimes the scanned code is smaller and the program crashes.
The variable ordr
comes from a textbox and the process in a class.
public string limpio()
{
if (ordr == "")
{
MessageBox.Show("Presione OK para cotinuar " + "\n" + "sin digiar Manufacturing Order", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
else
{
int cadena = ordr;
if (cadena < 14)
{
MessageBox.Show("Debe de contener mas digitos", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
if (cadena >= 14)
{
ordr = Convert.ToString(ordr.Substring(5,8));
}
}
return ordr;
}
What I need is that at the time of scanning I remove the prefixes and suffixes that the scanner has by default. An example of a scanned number is ~200|12345678~
. What I need to eliminate is the ~200|
of the beginning and the ~
of the end regardless of the amount found between those characters (~ 200 |, ~) .