I'm having problems with a For Each...Next loop
Hi all,
I'm trying to clear a load of textboxes in one go like this:
VB Code:
Private Sub cmdClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClear.Click
' Clear textboxes and graphics
Dim Txt As System.Windows.Forms.TextBox ' assign textboxes to object Txt
For Each Txt In gpbValues.Controls
Txt.Text = ""
Next Txt
End Sub
I get a runtime error of InvalidCastException every time. Can anyone tell me what I'm doing wrong please?