Ok i am going to try to explain this as good as possible.

I got a form, which i plan to use as a calendar/agenda.
I got labels for each week day, these will change each day.
Below each label(day), i got textboxes which are used to enter appointments in(these are saved in a database).

Can i make it so that all these textboxes get cleared for the next week.
So when for example i got appointments set for all week, i can see these as long as we are in the same week.
But when the next week is up on there, the boxes need to be empty.
But i still need to be able to request the information again should it be needed, by going back to previous days.

Being braking my head over this for a while now, but not sure if its even possible.

I would imagine the logical place to put the code to clear the textboxes (or repopulate them) is in the same place that determines and displays the labels above those same textboxes. You could place the labels and textboxes in a container (like a groupbox) and use a loop like the following

For Each ctrl as Control in GroupBox1.Controls
    If TypeOf ctrl Is TextBox Then
        Cast(ctrl,TextBox).Text = ""
    End If
Next

Another option would be to create references to the labels and textboxes in arrays such as

Dim labels() As Label   = {lblSunday,lblMonday,lblTuesday...
Dim appts()  As TextBox = {txtSunday,txtMonday,txtTuesday...

Then in your code you could just do

For i as Integer = 0 to 6
    appts(i).Text = ""
Next

You could use a similar loop to generate the correct dates for a given week and updpate the labels using the array.

or do a loop through all the textboxes and clear them (or what ever you want to do with them):

For Each t As TextBox In Me.Controls.OfType(Of TextBox)()
	t.Text = String.Empty
Next
Comments
i also dont know this quick method .:P thanks
"OfType(Of TextBox)" cool. I didn't know that one.
This article has been dead for over six months. Start a new discussion instead.