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.

Alright, gonna give that a try. thanks.

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
commented: "OfType(Of TextBox)" cool. I didn't know that one. +9
commented: i also dont know this quick method .:P thanks +5
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.