Hi,
you can use this piece of code to do what you asked :
char[] arrStr;
arrStr = Convert.ToString(textBox1.Text).ToCharArray();
for(int i = 0 ; i < arrStr.Length ; i ++)
{
MessageBox.Show(arrStr[i].ToString());
}
P.S : If this post helped you, please click 'Yes' on top of this post
Hth...
R. Thomas
[quoted text, click to view] "GTDriver" wrote:
> I would like to interate through each character in textboxcontrol.text.
> However, I'm having trouble accomplishing this.
>
> If I assign the value of a text property to a string variable and then do
> strVar.Length I'm not getting the value I expect for the length. When I try
> for strVar(1), it says strVar is not an array.
>
> How do I evaluate each character in textboxcontrol.text? This is probably
> vary simple but I must be overlooking something.
>
> --
> Sincerely,
>
[quoted text, click to view] GTDriver <GTDriver@discussions.microsoft.com> wrote:
> I would like to interate through each character in textboxcontrol.text.
> However, I'm having trouble accomplishing this.
>
> If I assign the value of a text property to a string variable and then do
> strVar.Length I'm not getting the value I expect for the length. When I try
> for strVar(1), it says strVar is not an array.
>
> How do I evaluate each character in textboxcontrol.text? This is probably
> vary simple but I must be overlooking something.
If you're using VB.NET, you can use strVar.Chars(1) etc.
You could also use a For Each loop:
For Each c as char in strVar
....
Next
--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet