For Each query

Discussion in 'Scripting & Programming' started by philbenson, Dec 9, 2005.

  1. philbenson

    philbenson Byte Poster

    208
    1
    20
    I'm using VB.Net and have placed a number of textboxes and a couple of labels in a panel on a form.

    I want to clear the text property of all the textboxes in the panel, but leave the labels alone.

    Is there a way I can do this using a For Each... loop? Eg;

    Dim tb as textbox
    For each tb in Panel1.Controls
    tb.clear()
    Next

    At present I have entered these lines into the click event for a button (outside the panel).

    This works providing I don't have any other controls apart from textboxes in the panel, but as soon as I mix control types in the panel, I get an error.

    Any ideas?
     
    Certifications: MCP, MCP+I, MCSE, MCSA, MCTS
    WIP: CCNA(?)
  2. simongrahamuk
    Honorary Member

    simongrahamuk Hmmmmmmm?

    6,205
    136
    199
    Can't help Phil, just a bump! :blink
     
  3. JonnyMX

    JonnyMX Petabyte Poster

    5,257
    220
    236
    Any reason you're not using a straight forward ASP.NET webform with a standard 'submit'/'reset' button?
    Just specify the properties of the reset button.

    <input type="submit" value="Submit Support Request">&nbsp;
    <input type="reset"value="ClearForm">
     
    Certifications: MCT, MCTS, i-Net+, CIW CI, Prince2, MSP, MCSD

Share This Page

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.