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

Thread: text boxes

  1. #1
    Join Date
    May 1999
    Location
    New Delhi, India
    Posts
    359

    text boxes

    hi there,
    I have a form with few controls in which some are textboxes and one command button here now i want that on the command click event the programmme should search each control and check it if it is a text box and if it is a text box then the contents of all the textboxes should be cleared.
    I need the codes for this.
    thankx...
    Pranay...

    pandit

    Let me sign the excellece...
    Whenever I hear "It can't be done", I know, I am close to success!!

  2. #2
    Join Date
    Feb 2002
    Posts
    111

    Re: text boxes

    for each ctrl in me.controls
    if typeofcontrol is textbox then
    textbox.text=""
    end if
    next


  3. #3
    Join Date
    May 1999
    Location
    New Delhi, India
    Posts
    359

    Re: text boxes

    this is giving an error as object required.


    pandit

    Let me sign the excellece...
    Whenever I hear "It can't be done", I know, I am close to success!!

  4. #4
    Join Date
    Mar 2001
    Posts
    71

    Re: text boxes

    Use the following code:

    for i = 0 to me.Controls.Count - 1
    If TypeOf me.Controls(i) is TextBox then
    me.Controls(i).Text = ""
    End If
    next





  5. #5
    Join Date
    May 1999
    Location
    New Delhi, India
    Posts
    359

    Re: text boxes

    thankx vivek it worked for me!
    also thanks to s_bist.
    Bist your code may also be correct but i didnt get it so it is a problem with me not with your code i think.
    cheers )

    pandit

    Let me sign the excellece...
    Whenever I hear "It can't be done", I know, I am close to success!!

  6. #6
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: text boxes

    Slight revision to s_Bist

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




    '
    '
    Please rate it if it answers the question
    or is useful.
    '
    John G

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