CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: FOR EACH

  1. #1
    Guest

    FOR EACH

    I'm trying to loop through all the text boxes on my form and clear the text property. Here is my code that gets an error. What am I doing wrong?

    Dim l_text As TextBox
    Dim l_form as frmPCReview 'frmPCReview is the name of my form with the controls

    For Each l_text In l_form.Controls

    l_text.text = ""

    Next

    Thanks,
    Darin
    [email protected]


  2. #2
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: FOR EACH

    Try this:


    private Sub Command1_Click()
    for Each Control In me
    If TypeOf Control is TextBox then Control.Text = ""
    next
    End Sub





    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

  3. #3
    Join Date
    Nov 1999
    Location
    Andhra Pradesh, India
    Posts
    3

    Re: FOR EACH

    Try the following with little changes in your code


    Dim l_text as control
    Dim l_form as frmPCReview 'frmPCReview is the name of my form with the controls
    for Each l_text In l_form.Controls
    if typeof I_text is textbox then
    l_text.text = ""
    end if
    next





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

Featured