Make into a loop?
-
I have the follow code in VB.NET 2005, i am trying to make it into a loop, is it possible, and if so, anyone fancy having a go at helping me at doing it, hints...etc? The numbers of labels and text boxes goes from 1-10, so it will have to loop, then add 1 to the integer value, something like that!!! HELP! CODE: --- Priv Sub txtInput1_TextChanged(…) Handles txtInput1.TextChanged If txtInput1.Text.ToLower = lblLetter1.Text Then lblLetter1.ForeColor = R : intScoreAll += 1 Else lblLetter1.ForeColor = W End If lblLetter1.BorderStyle = BorderStyle.None : txtInput1.Enabled = False txtInput2.Enabled = True lblLetter2.BorderStyle = BorderStyle.FixedSingle txtInput2.Focus() End Sub ---
-
I have the follow code in VB.NET 2005, i am trying to make it into a loop, is it possible, and if so, anyone fancy having a go at helping me at doing it, hints...etc? The numbers of labels and text boxes goes from 1-10, so it will have to loop, then add 1 to the integer value, something like that!!! HELP! CODE: --- Priv Sub txtInput1_TextChanged(…) Handles txtInput1.TextChanged If txtInput1.Text.ToLower = lblLetter1.Text Then lblLetter1.ForeColor = R : intScoreAll += 1 Else lblLetter1.ForeColor = W End If lblLetter1.BorderStyle = BorderStyle.None : txtInput1.Enabled = False txtInput2.Enabled = True lblLetter2.BorderStyle = BorderStyle.FixedSingle txtInput2.Focus() End Sub ---
You can use a foreach loop on the Controls collection and look for items by name or tag, or use dynamic type checking to work out which items are textboxes.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )