Results 1 to 5 of 5

Thread: I'm having problems with a For Each...Next loop

Threaded View

  1. #1

    Thread Starter
    PowerPoster SuperSparks's Avatar
    Join Date
    May 2003
    Location
    London, England
    Posts
    265

    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:
    1. Private Sub cmdClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClear.Click
    2.  
    3.         ' Clear textboxes and graphics
    4.         Dim Txt As System.Windows.Forms.TextBox                                    ' assign textboxes to object Txt
    5.         For Each Txt In gpbValues.Controls
    6.             Txt.Text = ""
    7.         Next Txt
    8.  
    9.  
    10.     End Sub

    I get a runtime error of InvalidCastException every time. Can anyone tell me what I'm doing wrong please?
    Last edited by SuperSparks; Jun 28th, 2003 at 01:26 PM.
    Nick.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width