Results 1 to 3 of 3

Thread: Clearing TextBox arrays ????

  1. #1

    Thread Starter
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330

    Post

    I have four TextBox arrays on a form. e.g. Text1(0) through (5), Text2(0) through (5), etc.

    What's the best way to Clear these?

    I'm currently using a For/Next loop but, being arrays, I'm wondering if something like Erase might work. I get an "Expected Array" error when trying to use Erase.

    Thanks,
    Al.


    ------------------
    A computer is a tool, not a toy.
    <A HREF="mailto:[email protected]
    [email protected]">[email protected]
    [email protected]</A>


  2. #2
    Guest

    Post


    Private Sub ClearTextBoxes()
    Dim ctl as Control

    For Each ctl in Me.Controls

    If TypeOf ctl Is TextBox Then
    ctl.Text = ""
    End If

    Next

    End Sub

    ...that'll clear out every textbox on the active form regardless of it's name...

  3. #3
    Lively Member Maartin's Avatar
    Join Date
    Jan 2000
    Location
    Benoni, Gauteng, South-Africa
    Posts
    99

    Post

    Just beware of the way listed above that you will clear out all text boxes on the form. Other wise it is fine.

    If you're using this code on the same form ok, but if you use it in a module pass the form thru to the module and you can then use it in various places.

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