Hey all, I'm trying to split a string of characters and after a day of trying every possible way of splitting a string into groups of 7, I'm still hopelessly stuck!
Bascially, the user enters/pastes a string into "txtArea" (the first text box), then click an encrypt button... the program then encrypts the string from txtArea into a string in txtArea2... Without giving away the heart of my program, I'll give you an idea of what's found in txtArea2:
This is exactly how the string is presented in txtArea2:
>><>><<<>>><><<>>>><<<<<>><<
This is how the string looks per original character:
>><>><< <>>><>< <>>>><< <<<>><<
Now, my problem comes with not being able to split the entire original txtArea2 string (up to and over 50,000 characters) into groups of strings consisting of 7 characters ie:
>><>><<
The only way to decrypt the encrypted string is to have it in a block of 7 characters (still string data type, I'm not using char or char[] data types)
Another possible solution would be to pad each block of 7 with spaces either side:
... >><>><< ....
This would be an easier way to decrypt using my exe...
Sorry to ask such a standard question! I'm just really stuck! I've tried quadrillions of different ways of doing this but still haven't come up with a solution! I'm trying to stay away from implementing embedded classes so a few lines of code would really sort this out!
int x = 0;
while (x != txtArea2.Text.Length)
{
int i;
int j = i + 7;
for (i = 0; i < txtArea2.Text.Length; i++)
{
string splitter = txtArea2.Text.Substring(i, j);
txtArea2.Text = txtArea2.Text + splitter.ToString();
}
}
I've also tried:
.Substring(0, 7)
.Substring(i, j)
(Where i and j represent the start and finishing index of each 7 group)
NOTHING though, SO stuck!
I'd really appreciate a little bit of help with this little problem!
Thanks everyone who reads!! Take care
Rob