Accessing textboxes within a groupbox

Hello,
I have a groupbox with two textboxes within it. I need to determine if they have been modified. How can I do this?
LVL 1
caddsmanAsked:
Who is Participating?
 
frodomanCommented:
If you're trying to find out if any of the text boxes have been changed, then the only problem with above code is that WasChanged will take on the value of the last text box in the group.

Instead you might consider:

      Dim ctl As TextBox
      Dim WasChanged As Boolean = False

      For Each ctl In Me.GroupBox1.Controls
         If ctl.Modified then
            WasChanged = True
            Exit For
         End if
      Next

0
 
caddsmanAuthor Commented:
For clarification, how do I access the textboxes within the groupbox and determine if those textboxes have been modified?
0
 
Bob LearnedCommented:
If you know there only text boxes in the group box, you could loop through each text box in the group box controls:

      Dim ctl As TextBox
      Dim WasChanged As Boolean

      For Each ctl In Me.GroupBox1.Controls

         WasChanged = ctl.Modified

      Next
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
Bob LearnedCommented:
That's what you get for 5 minutes of coding in the comment block without testing.
0
 
frodomanCommented:
Well, we've all done that 1 or 2 (thousand) times ;-)
0
 
caddsmanAuthor Commented:
Oops, sorry frodoman. I meant to give yo the points. :(
0
 
Bob LearnedCommented:
You can always have a moderator fix this.  Ask in Community Support to have this question fixed.
0
 
Bob LearnedCommented:
You might also think about splitting the points.  If one person starts and idea, and another fixes any problems, then you can say that my comments was an 'Assisted' comment.
0
 
frodomanCommented:
caddsman,

I'm all for splitting the points on this one.  TheLearnedOne rang in first with the basic code - I just fixed a simple logic error in the algorythm.

Cheers,

Frodoman
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.